@aslaluroba/help-center-react 3.2.12 → 3.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -39540,17 +39540,19 @@ var HelpscreenOption = _ref => {
39540
39540
  isSelected,
39541
39541
  onClick
39542
39542
  } = _ref;
39543
+ var _a;
39544
+ var chatWithUs = (_a = option.chatWithUs) !== null && _a !== void 0 ? _a : true;
39543
39545
  return jsxs("div", {
39544
- role: "button",
39545
- tabIndex: 0,
39546
- className: cn('babylai:flex babylai:flex-col babylai:gap-2 babylai:p-6 babylai:rounded-3xl babylai:text-start babylai:border babylai:border-black-white-200 babylai:bg-card babylai:cursor-pointer', 'babylai:transition-all babylai:duration-200 babylai:ease-out', 'babylai:active:scale-[0.98] babylai:active:opacity-95', isSelected && 'babylai:ring babylai:ring-primary-500 babylai:shadow-md'),
39547
- onClick: onClick,
39548
- onKeyDown: e => {
39546
+ role: chatWithUs ? 'button' : undefined,
39547
+ tabIndex: chatWithUs ? 0 : undefined,
39548
+ className: cn('babylai:flex babylai:flex-col babylai:gap-2 babylai:p-6 babylai:rounded-3xl babylai:text-start babylai:border babylai:border-black-white-200 babylai:bg-card', 'babylai:transition-all babylai:duration-200 babylai:ease-out', chatWithUs ? 'babylai:cursor-pointer babylai:active:scale-[0.98] babylai:active:opacity-95' : 'babylai:cursor-default', isSelected && 'babylai:ring babylai:ring-primary-500 babylai:shadow-md'),
39549
+ onClick: chatWithUs ? onClick : undefined,
39550
+ onKeyDown: chatWithUs ? e => {
39549
39551
  if (e.key === 'Enter' || e.key === ' ') {
39550
39552
  e.preventDefault();
39551
39553
  onClick();
39552
39554
  }
39553
- },
39555
+ } : undefined,
39554
39556
  children: [jsx("h2", {
39555
39557
  className: "babylai:text-base! babylai:font-semibold! babylai:text-card-foreground",
39556
39558
  dir: "auto",
@@ -39570,7 +39572,8 @@ var HelpscreenList = _ref => {
39570
39572
  selectedOption,
39571
39573
  onToggleOption,
39572
39574
  onStartChat,
39573
- showChatNowButton = true
39575
+ showChatNowButton = true,
39576
+ chatWithUs = true
39574
39577
  } = _ref;
39575
39578
  var {
39576
39579
  t
@@ -39589,7 +39592,7 @@ var HelpscreenList = _ref => {
39589
39592
  children: jsxs(Button, {
39590
39593
  variant: 'default',
39591
39594
  onClick: onStartChat,
39592
- disabled: !selectedOption,
39595
+ disabled: !selectedOption || !chatWithUs,
39593
39596
  children: [t('homeSdk.chatNow'), jsx(ForwardRef$8, {
39594
39597
  className: "babylai:w-6 babylai:h-6"
39595
39598
  })]
@@ -39606,7 +39609,7 @@ var OptionsListScreen = _ref => {
39606
39609
  handleMinimize,
39607
39610
  hasActiveSession = false
39608
39611
  } = _ref;
39609
- var _a, _b, _c, _d;
39612
+ var _a, _b, _c, _d, _e;
39610
39613
  var [selectedOption, setSelectedOption] = useState(null);
39611
39614
  useEffect(() => {
39612
39615
  // Reset selected option when helpScreen changes
@@ -39642,7 +39645,8 @@ var OptionsListScreen = _ref => {
39642
39645
  selectedOption: selectedOption,
39643
39646
  onToggleOption: handleToggleExpandOption,
39644
39647
  onStartChat: handleStartChatWithSelected,
39645
- showChatNowButton: !hasActiveSession
39648
+ showChatNowButton: !hasActiveSession,
39649
+ chatWithUs: (_e = helpScreen === null || helpScreen === void 0 ? void 0 : helpScreen.chatWithUs) !== null && _e !== void 0 ? _e : true
39646
39650
  })]
39647
39651
  }), jsx(PoweredBy, {})]
39648
39652
  });
@@ -40246,20 +40250,23 @@ var HelpCenterContent = _ref => {
40246
40250
  var _ref2 = _asyncToGenerator(function* (options) {
40247
40251
  if (!sessionId || !selectedOption) return;
40248
40252
  var fromChatScreen = (options === null || options === void 0 ? void 0 : options.fromChatScreen) === true;
40253
+ // When Ably sends end_session (e.g. admin closed from dashboard), skip close API call
40254
+ var sessionClosedByServer = (options === null || options === void 0 ? void 0 : options.sessionClosedByServer) === true;
40249
40255
  try {
40250
40256
  yield ClientAblyService.stopConnection();
40251
40257
  setIsAblyConnected(false);
40252
40258
  setAssistantStatus('idle');
40253
- var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
40254
- language: language
40255
- });
40256
- if (!response.ok) throw new Error('Failed to close chat session');
40259
+ if (!sessionClosedByServer) {
40260
+ var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
40261
+ language: language
40262
+ });
40263
+ if (!response.ok) throw new Error('Failed to close chat session');
40264
+ }
40257
40265
  setReviewSessionId(sessionId);
40258
40266
  setSessionId(null);
40259
40267
  if (fromChatScreen) {
40260
40268
  setInChatReviewSessionId(sessionId);
40261
40269
  setIsChatClosed(true);
40262
- // Keep selectedOption and messages; do not open popup
40263
40270
  } else {
40264
40271
  setSelectedOption(null);
40265
40272
  setMessages([]);
@@ -40463,10 +40470,11 @@ var HelpCenterContent = _ref => {
40463
40470
  actionHandler.registerHandler('needs_agent', () => {
40464
40471
  setNeedsAgent(true);
40465
40472
  });
40466
- // "end_session" → close session and show in-chat review (user stays in chat)
40473
+ // "end_session" → session was closed by server (e.g. admin from dashboard); update local state only, do not call close API
40467
40474
  actionHandler.registerHandler('end_session', () => {
40468
40475
  void handleEndChat({
40469
- fromChatScreen: true
40476
+ fromChatScreen: true,
40477
+ sessionClosedByServer: true
40470
40478
  });
40471
40479
  });
40472
40480
  return () => {