@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.js CHANGED
@@ -39560,17 +39560,19 @@ var HelpscreenOption = _ref => {
39560
39560
  isSelected,
39561
39561
  onClick
39562
39562
  } = _ref;
39563
+ var _a;
39564
+ var chatWithUs = (_a = option.chatWithUs) !== null && _a !== void 0 ? _a : true;
39563
39565
  return jsxRuntime.jsxs("div", {
39564
- role: "button",
39565
- tabIndex: 0,
39566
- 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'),
39567
- onClick: onClick,
39568
- onKeyDown: e => {
39566
+ role: chatWithUs ? 'button' : undefined,
39567
+ tabIndex: chatWithUs ? 0 : undefined,
39568
+ 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'),
39569
+ onClick: chatWithUs ? onClick : undefined,
39570
+ onKeyDown: chatWithUs ? e => {
39569
39571
  if (e.key === 'Enter' || e.key === ' ') {
39570
39572
  e.preventDefault();
39571
39573
  onClick();
39572
39574
  }
39573
- },
39575
+ } : undefined,
39574
39576
  children: [jsxRuntime.jsx("h2", {
39575
39577
  className: "babylai:text-base! babylai:font-semibold! babylai:text-card-foreground",
39576
39578
  dir: "auto",
@@ -39590,7 +39592,8 @@ var HelpscreenList = _ref => {
39590
39592
  selectedOption,
39591
39593
  onToggleOption,
39592
39594
  onStartChat,
39593
- showChatNowButton = true
39595
+ showChatNowButton = true,
39596
+ chatWithUs = true
39594
39597
  } = _ref;
39595
39598
  var {
39596
39599
  t
@@ -39609,7 +39612,7 @@ var HelpscreenList = _ref => {
39609
39612
  children: jsxRuntime.jsxs(Button, {
39610
39613
  variant: 'default',
39611
39614
  onClick: onStartChat,
39612
- disabled: !selectedOption,
39615
+ disabled: !selectedOption || !chatWithUs,
39613
39616
  children: [t('homeSdk.chatNow'), jsxRuntime.jsx(ForwardRef$8, {
39614
39617
  className: "babylai:w-6 babylai:h-6"
39615
39618
  })]
@@ -39626,7 +39629,7 @@ var OptionsListScreen = _ref => {
39626
39629
  handleMinimize,
39627
39630
  hasActiveSession = false
39628
39631
  } = _ref;
39629
- var _a, _b, _c, _d;
39632
+ var _a, _b, _c, _d, _e;
39630
39633
  var [selectedOption, setSelectedOption] = React.useState(null);
39631
39634
  React.useEffect(() => {
39632
39635
  // Reset selected option when helpScreen changes
@@ -39662,7 +39665,8 @@ var OptionsListScreen = _ref => {
39662
39665
  selectedOption: selectedOption,
39663
39666
  onToggleOption: handleToggleExpandOption,
39664
39667
  onStartChat: handleStartChatWithSelected,
39665
- showChatNowButton: !hasActiveSession
39668
+ showChatNowButton: !hasActiveSession,
39669
+ chatWithUs: (_e = helpScreen === null || helpScreen === void 0 ? void 0 : helpScreen.chatWithUs) !== null && _e !== void 0 ? _e : true
39666
39670
  })]
39667
39671
  }), jsxRuntime.jsx(PoweredBy, {})]
39668
39672
  });
@@ -40266,20 +40270,23 @@ var HelpCenterContent = _ref => {
40266
40270
  var _ref2 = _asyncToGenerator(function* (options) {
40267
40271
  if (!sessionId || !selectedOption) return;
40268
40272
  var fromChatScreen = (options === null || options === void 0 ? void 0 : options.fromChatScreen) === true;
40273
+ // When Ably sends end_session (e.g. admin closed from dashboard), skip close API call
40274
+ var sessionClosedByServer = (options === null || options === void 0 ? void 0 : options.sessionClosedByServer) === true;
40269
40275
  try {
40270
40276
  yield ClientAblyService.stopConnection();
40271
40277
  setIsAblyConnected(false);
40272
40278
  setAssistantStatus('idle');
40273
- var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
40274
- language: language
40275
- });
40276
- if (!response.ok) throw new Error('Failed to close chat session');
40279
+ if (!sessionClosedByServer) {
40280
+ var response = yield apiRequest("Client/ClientChatSession/".concat(sessionId, "/close"), 'POST', null, {
40281
+ language: language
40282
+ });
40283
+ if (!response.ok) throw new Error('Failed to close chat session');
40284
+ }
40277
40285
  setReviewSessionId(sessionId);
40278
40286
  setSessionId(null);
40279
40287
  if (fromChatScreen) {
40280
40288
  setInChatReviewSessionId(sessionId);
40281
40289
  setIsChatClosed(true);
40282
- // Keep selectedOption and messages; do not open popup
40283
40290
  } else {
40284
40291
  setSelectedOption(null);
40285
40292
  setMessages([]);
@@ -40483,10 +40490,11 @@ var HelpCenterContent = _ref => {
40483
40490
  actionHandler.registerHandler('needs_agent', () => {
40484
40491
  setNeedsAgent(true);
40485
40492
  });
40486
- // "end_session" → close session and show in-chat review (user stays in chat)
40493
+ // "end_session" → session was closed by server (e.g. admin from dashboard); update local state only, do not call close API
40487
40494
  actionHandler.registerHandler('end_session', () => {
40488
40495
  void handleEndChat({
40489
- fromChatScreen: true
40496
+ fromChatScreen: true,
40497
+ sessionClosedByServer: true
40490
40498
  });
40491
40499
  });
40492
40500
  return () => {