@rh-support/react-context 2.5.81 → 2.5.82

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.
@@ -3,17 +3,14 @@ import { Button, ButtonVariant, Popover, PopoverPosition, Spinner } from '@patte
3
3
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
4
4
  import React, { useRef, useState } from 'react';
5
5
  import { Trans, useTranslation } from 'react-i18next';
6
- import { FeatureAnnouncementKeys, NewFeaturePopoverAnnouncement, useChatInit, usePreChatFormDetails } from '../..';
6
+ import { FeatureAnnouncementKeys, NewFeaturePopoverAnnouncement, useChatInit } from '../..';
7
7
  import { ChatSVGIcon } from './ChatSVGIcon';
8
8
  export const EmbeddedServiceChat = () => {
9
- var _a;
10
9
  const componentRef = useRef(null);
11
- const { loadingChat, isChatStarted, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser, chatServiceNotAvailable, hasBlockedByCookie, } = useChatInit();
10
+ const { loadingChat, isChatStarted, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser, chatServiceNotAvailable, hasBlockedByCookie, sessionId, } = useChatInit();
12
11
  const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
13
12
  const [chatClicked, setChatClicked] = useState(false);
14
13
  const { t } = useTranslation();
15
- const getChatFormDetails = usePreChatFormDetails();
16
- const sessionId = (_a = getChatFormDetails().find((item) => item.label === 'SessionId')) === null || _a === void 0 ? void 0 : _a.value;
17
14
  const shouldClose = () => {
18
15
  setIsBlockedErrorBoxVisible(false);
19
16
  };
@@ -45,8 +42,10 @@ export const EmbeddedServiceChat = () => {
45
42
  return React.createElement(React.Fragment, null);
46
43
  return loadingChat ? (React.createElement("div", { className: "chatButton" },
47
44
  React.createElement(Spinner, { diameter: "28px", className: "pf-v6-u-m-xs" }))) : hasBlockedByCookie && chatClicked && document.querySelector('#teconsent a[role="link"]') !== null ? (chatErrorMessagePopover('cookie')) : (hasBlockedByBrowser || hasChatDomainsBlocked || !sessionId) && chatClicked ? (chatErrorMessagePopover()) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: () => {
48
- onStartChat();
49
45
  setChatClicked(true);
46
+ if (sessionId) {
47
+ onStartChat();
48
+ }
50
49
  }, "data-tracking-id": "embedded-service-chat", ref: componentRef, id: "chat-bot-wrapper" },
51
50
  React.createElement(ChatSVGIcon, null),
52
51
  React.createElement(NewFeaturePopoverAnnouncement, { "aria-label": t('Support now has a chatbot (beta). Try it if you need help with a case.'), featureName: FeatureAnnouncementKeys.CHAT_BOT, sectionRef: componentRef, bodyContent: React.createElement("div", null,
@@ -7,6 +7,7 @@ interface IChatOptions {
7
7
  onStartChat: () => void;
8
8
  chatServiceNotAvailable: boolean;
9
9
  hasBlockedByCookie: boolean;
10
+ sessionId: string;
10
11
  }
11
12
  /**
12
13
  * This hook is used for setting chat up and listing custom event of chat.
@@ -1 +1 @@
1
- {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,YA0H3D,CAAC"}
1
+ {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,YA8H3D,CAAC"}
@@ -19,6 +19,7 @@ import { usePreChatFormDetails } from './usePreChatFormDetails';
19
19
  * @returns
20
20
  */
21
21
  export const useChatInit = (initialState = false) => {
22
+ var _a;
22
23
  const [isChatStarted, setChatStart] = useState(initialState);
23
24
  // Need to set loading status true as it will prevent starting chat before loading necessary dependencies
24
25
  const [loadingChat, setLoadingChat] = useState(true);
@@ -120,6 +121,7 @@ export const useChatInit = (initialState = false) => {
120
121
  clearTimeout(blockedByNetworkTimeOut);
121
122
  });
122
123
  };
124
+ const sessionId = ((_a = getChatFormDetails().find((item) => item.label === 'SessionId')) === null || _a === void 0 ? void 0 : _a.value) || '';
123
125
  return {
124
126
  loadingChat,
125
127
  isChatStarted,
@@ -129,5 +131,6 @@ export const useChatInit = (initialState = false) => {
129
131
  onStartChat,
130
132
  chatServiceNotAvailable,
131
133
  hasBlockedByCookie,
134
+ sessionId,
132
135
  };
133
136
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.81",
3
+ "version": "2.5.82",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -93,5 +93,5 @@
93
93
  "defaults and supports es6-module",
94
94
  "maintained node versions"
95
95
  ],
96
- "gitHead": "5bd0b48bd344b4362efb801ad01b96f0bba0df1a"
96
+ "gitHead": "d8cde6c6c2d28af9c0762c55fe1bc52e6104208b"
97
97
  }