@rh-support/react-context 2.5.322 → 2.5.327

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.
Files changed (43) hide show
  1. package/lib/esm/GlobalContextWrapper.d.ts +3 -1
  2. package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
  3. package/lib/esm/GlobalContextWrapper.js +8 -26
  4. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts +2 -1
  5. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts.map +1 -1
  6. package/lib/esm/components/AccountSelector/AccountSelectorInternal.js +37 -93
  7. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +0 -6
  8. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
  9. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +51 -17
  10. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +12 -0
  11. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +1 -0
  12. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +29 -0
  13. package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +51 -1
  14. package/lib/esm/components/SharedModals/CSSUserModal.d.ts.map +1 -1
  15. package/lib/esm/components/SharedModals/CSSUserModal.js +1 -2
  16. package/lib/esm/components/SharedModals/CloseCaseModal.js +1 -1
  17. package/lib/esm/hooks/index.d.ts +1 -0
  18. package/lib/esm/hooks/index.d.ts.map +1 -1
  19. package/lib/esm/hooks/index.js +1 -0
  20. package/lib/esm/hooks/useCanEditCase.d.ts +1 -2
  21. package/lib/esm/hooks/useCanEditCase.d.ts.map +1 -1
  22. package/lib/esm/hooks/useCanEditCase.js +3 -20
  23. package/lib/esm/hooks/useChatConfig.d.ts +17 -9
  24. package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
  25. package/lib/esm/hooks/useChatConfig.js +43 -11
  26. package/lib/esm/hooks/useChatInit.d.ts +13 -9
  27. package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
  28. package/lib/esm/hooks/useChatInit.js +119 -63
  29. package/lib/esm/hooks/usePreChatFormDetails.d.ts +12 -0
  30. package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +1 -0
  31. package/lib/esm/hooks/usePreChatFormDetails.js +61 -0
  32. package/lib/esm/index.d.ts +0 -1
  33. package/lib/esm/index.d.ts.map +1 -1
  34. package/lib/esm/index.js +0 -2
  35. package/lib/esm/reducers/GlobalMetadataHelpers.d.ts.map +1 -1
  36. package/lib/esm/reducers/GlobalMetadataHelpers.js +6 -2
  37. package/lib/esm/reducers/GlobalMetadataReducer.d.ts +16 -51
  38. package/lib/esm/reducers/GlobalMetadataReducer.d.ts.map +1 -1
  39. package/lib/esm/reducers/GlobalMetadataReducer.js +89 -265
  40. package/package.json +7 -10
  41. package/lib/esm/context/CaseStatusContext.d.ts +0 -9
  42. package/lib/esm/context/CaseStatusContext.d.ts.map +0 -1
  43. package/lib/esm/context/CaseStatusContext.js +0 -5
@@ -1,25 +1,8 @@
1
- import { ToastNotification } from '@rh-support/components';
2
- import { isCaseArchivedStatus } from '@rh-support/utils';
3
- import { useContext } from 'react';
4
- import { useTranslation } from 'react-i18next';
5
- import { CaseStatusContext } from '../context/CaseStatusContext';
6
1
  import { useSubscriptionAbused } from './useSubscriptionAbused';
7
- export function useCanEditCase(caseStatusOverride) {
8
- const { t } = useTranslation();
9
- const contextCaseStatus = useContext(CaseStatusContext);
10
- const caseStatus = caseStatusOverride !== null && caseStatusOverride !== void 0 ? caseStatusOverride : contextCaseStatus;
2
+ export function useCanEditCase() {
11
3
  const { checkAndShowSubscriptionAbused, isAccountFreezed } = useSubscriptionAbused();
12
- const isCaseArchived = isCaseArchivedStatus(caseStatus);
13
- const alert = () => {
14
- if (isCaseArchived) {
15
- ToastNotification.addInfoMessage(t('This case has been archived and can no longer be updated. Contact us or open a new case if you need further assistance.'));
16
- return true;
17
- }
18
- return checkAndShowSubscriptionAbused();
19
- };
20
4
  return {
21
- alert,
22
- isCaseNotEditable: isAccountFreezed || isCaseArchived,
23
- isCaseArchived,
5
+ alert: checkAndShowSubscriptionAbused,
6
+ isCaseNotEditable: isAccountFreezed,
24
7
  };
25
8
  }
@@ -1,12 +1,20 @@
1
- export interface IEnhancedChatConfig {
2
- orgId: string;
3
- deploymentDevName: string;
4
- siteURL: string;
5
- scrt2URL: string;
6
- bootstrapScriptURL: string;
7
- }
8
1
  /**
9
- * Returns Salesforce Enhanced Messaging configuration for the current environment.
2
+ *
3
+ * This hook is used for selected chat configuration based on environment
10
4
  */
11
- export declare const useChatConfig: () => IEnhancedChatConfig;
5
+ export declare const useChatConfig: () => {
6
+ host: string;
7
+ sandBox: string;
8
+ gslbBaseURL: string;
9
+ key: string;
10
+ appName: string;
11
+ extra: {
12
+ baseLiveAgentContentURL: string;
13
+ deploymentId: string;
14
+ buttonId: string;
15
+ baseLiveAgentURL: string;
16
+ eswLiveAgentDevName: string;
17
+ isOfflineSupportEnabled: boolean;
18
+ };
19
+ };
12
20
  //# sourceMappingURL=useChatConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,mBAwBhC,CAAC"}
1
+ {"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAqDzB,CAAC"}
@@ -1,26 +1,58 @@
1
1
  import { Env } from '@cee-eng/hydrajs';
2
2
  /**
3
- * Returns Salesforce Enhanced Messaging configuration for the current environment.
3
+ *
4
+ * This hook is used for selected chat configuration based on environment
4
5
  */
5
6
  export const useChatConfig = () => {
6
7
  const env = Env.getEnvName();
7
8
  switch (env) {
8
9
  case Env.EnvNames.QA:
10
+ return {
11
+ host: 'https://gss--qa.sandbox.my.salesforce.com',
12
+ sandBox: 'https://gss--qa.sandbox.my.site.com/botchat',
13
+ gslbBaseURL: 'https://service.force.com',
14
+ key: '00D8I0000016hOv',
15
+ appName: 'RedHatChatBot',
16
+ extra: {
17
+ baseLiveAgentContentURL: 'https://c.la4-c1cs-ia4.salesforceliveagent.com/content',
18
+ deploymentId: '5726R000000sXtR',
19
+ buttonId: '5736R000000wk2n',
20
+ baseLiveAgentURL: 'https://d.la4-c1cs-ia4.salesforceliveagent.com/chat',
21
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
22
+ isOfflineSupportEnabled: false,
23
+ },
24
+ };
9
25
  case Env.EnvNames.STAGE:
10
26
  return {
11
- orgId: '00DEk00000R3Rgr',
12
- deploymentDevName: 'Red_Hat_Enhanced_Chat',
13
- siteURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668',
14
- scrt2URL: 'https://redhatsupport--stage.sandbox.my.salesforce-scrt.com',
15
- bootstrapScriptURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668/assets/js/bootstrap.min.js',
27
+ host: 'https://gss--stage2.sandbox.my.salesforce.com',
28
+ sandBox: 'https://gss--stage2.sandbox.my.site.com/botchat',
29
+ gslbBaseURL: 'https://service.force.com',
30
+ key: '00DD7000000jd7T',
31
+ appName: 'RedHatChatBot',
32
+ extra: {
33
+ baseLiveAgentContentURL: 'https://c.la3-c1cs-ia7.salesforceliveagent.com/content',
34
+ deploymentId: '5726R000000sXtR',
35
+ buttonId: '5736R000000wk2n',
36
+ baseLiveAgentURL: 'https://d.la3-c1cs-ia7.salesforceliveagent.com/chat',
37
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
38
+ isOfflineSupportEnabled: false,
39
+ },
16
40
  };
17
41
  default:
18
42
  return {
19
- orgId: '00DEk00000R3Rgr',
20
- deploymentDevName: 'Red_Hat_Enhanced_Chat',
21
- siteURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668',
22
- scrt2URL: 'https://redhatsupport--stage.sandbox.my.salesforce-scrt.com',
23
- bootstrapScriptURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668/assets/js/bootstrap.min.js',
43
+ host: 'https://gss.my.salesforce.com',
44
+ sandBox: 'https://gss.my.site.com/botchat',
45
+ gslbBaseURL: 'https://service.force.com',
46
+ key: '00DA0000000HxWH',
47
+ appName: 'RedHatChatBot',
48
+ extra: {
49
+ baseLiveAgentContentURL: 'https://c.la3-c1-ia6.salesforceliveagent.com/content',
50
+ deploymentId: '5726R000000sXtR',
51
+ buttonId: '5736R000000wk2n',
52
+ baseLiveAgentURL: 'https://d.la3-c1-ia6.salesforceliveagent.com/chat',
53
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
54
+ isOfflineSupportEnabled: false,
55
+ },
24
56
  };
25
57
  }
26
58
  };
@@ -1,18 +1,22 @@
1
+ import { IPreChatFormDetails } from './usePreChatFormDetails';
1
2
  interface IChatOptions {
2
3
  loadingChat: boolean;
4
+ isChatStarted: boolean;
5
+ hasBlockedByBrowser: boolean;
6
+ hasChatDomainsBlocked: boolean;
7
+ initEmbedChat: () => void;
8
+ onStartChat: () => void;
3
9
  chatServiceNotAvailable: boolean;
4
10
  hasBlockedByCookie: boolean;
11
+ /** Pre-chat form details (SSO, sessionId, etc.). From single usePreChatFormDetails instance to avoid duplicate API calls. */
12
+ getChatFormDetails: () => IPreChatFormDetails[];
5
13
  }
6
14
  /**
7
- * Dynamically loads the Salesforce Enhanced Messaging bootstrap script and
8
- * calls `embeddedservice_bootstrap.init()` once the script is ready.
9
- *
10
- * The script is injected only after TrustArc functional-cookie consent is
11
- * confirmed, and the `onload` callback is used instead of polling so we
12
- * never race against network latency.
13
- *
14
- * @see https://developer.salesforce.com/docs/service/messaging-web/guide/set-up-embedded-messaging.html
15
+ * This hook is used for setting chat up and listing custom event of chat.
16
+ * for more details https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm
17
+ * @param initialState
18
+ * @returns
15
19
  */
16
- export declare const useChatInit: () => IChatOptions;
20
+ export declare const useChatInit: (initialState?: boolean) => IChatOptions;
17
21
  export {};
18
22
  //# sourceMappingURL=useChatInit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,QAAO,YAsE9B,CAAC"}
1
+ {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AAErF,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,6HAA6H;IAC7H,kBAAkB,EAAE,MAAM,mBAAmB,EAAE,CAAC;CACnD;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,eAAc,OAAe,KAAG,YA4H3D,CAAC"}
@@ -1,78 +1,134 @@
1
- import { getCookieValue } from '@rh-support/utils';
2
- import { useContext, useEffect, useRef, useState } from 'react';
3
- import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { enableScripts, getCookieValue, waitForWindowVariable } from '@rh-support/utils';
11
+ import { useEffect, useState } from 'react';
12
+ import { extraPreChatInfo } from '../components/EmbeddedServiceChat/ExtraPreChatInfo';
4
13
  import { useChatConfig } from './useChatConfig';
14
+ import { usePreChatFormDetails } from './usePreChatFormDetails';
5
15
  /**
6
- * Dynamically loads the Salesforce Enhanced Messaging bootstrap script and
7
- * calls `embeddedservice_bootstrap.init()` once the script is ready.
8
- *
9
- * The script is injected only after TrustArc functional-cookie consent is
10
- * confirmed, and the `onload` callback is used instead of polling so we
11
- * never race against network latency.
12
- *
13
- * @see https://developer.salesforce.com/docs/service/messaging-web/guide/set-up-embedded-messaging.html
16
+ * This hook is used for setting chat up and listing custom event of chat.
17
+ * for more details https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm
18
+ * @param initialState
19
+ * @returns
14
20
  */
15
- export const useChatInit = () => {
21
+ export const useChatInit = (initialState = false) => {
22
+ const [isChatStarted, setChatStart] = useState(initialState);
23
+ // Need to set loading status true as it will prevent starting chat before loading necessary dependencies
16
24
  const [loadingChat, setLoadingChat] = useState(true);
25
+ const [hasBlockedByBrowser, setHasBlockedByBrowser] = useState(false);
26
+ const [hasChatDomainsBlocked, setHasChatDomainsBlocked] = useState(false);
17
27
  const [chatServiceNotAvailable, setChatServiceNotAvailable] = useState(false);
18
28
  const [hasBlockedByCookie, setHasBlockedByCookie] = useState(false);
19
- const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
20
- const ssoName = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data.getSSOUsername();
21
- const fullName = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data.getUserFullName();
22
- const { orgId, deploymentDevName, siteURL, scrt2URL, bootstrapScriptURL } = useChatConfig();
23
- const ssoNameRef = useRef(ssoName);
24
- ssoNameRef.current = ssoName;
25
- const fullNameRef = useRef(fullName);
26
- fullNameRef.current = fullName;
29
+ const getChatFormDetails = usePreChatFormDetails();
30
+ const { host, sandBox, gslbBaseURL, key, appName, extra } = useChatConfig();
27
31
  useEffect(() => {
28
- var _a;
29
- const preferences = getCookieValue('cmapi_cookie_privacy');
30
- if (!preferences || !preferences.includes('2')) {
32
+ /*
33
+ retrieve TrustArc cookie value
34
+ value is like "permit 1,2,3" when all cookie types are accepted
35
+ 1-> Required Cookies
36
+ 2-> Functional Cookies
37
+ 3-> Advertising Cookies
38
+ we need to make sure 2 that indicates functional cookies is included in value
39
+ */
40
+ var preferences = getCookieValue('cmapi_cookie_privacy');
41
+ if (preferences && preferences.includes('2')) {
42
+ // based on TrustArc cookie consent, cookie is allowed
43
+ enableScripts();
44
+ const initChatService = () => __awaiter(void 0, void 0, void 0, function* () {
45
+ try {
46
+ yield waitForWindowVariable('embedded_svc', 10000);
47
+ initEmbedChat();
48
+ }
49
+ catch (e) {
50
+ console.error('Error: Chat service not available', e.message);
51
+ setLoadingChat(false);
52
+ }
53
+ });
54
+ initChatService();
55
+ }
56
+ else {
31
57
  setHasBlockedByCookie(true);
32
- setLoadingChat(false);
33
- return;
34
58
  }
35
- const onMessagingReady = () => {
36
- window.embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({
37
- username: ssoNameRef.current,
38
- fullName: fullNameRef.current,
59
+ setLoadingChat(false);
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ }, []);
62
+ const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
63
+ setLoadingChat(true);
64
+ try {
65
+ // if chat didn't start after a long wait
66
+ // then we assume browser has blocked the script
67
+ const blockedTimeOut = setTimeout(() => {
68
+ if (!window.$Lightning) {
69
+ setHasBlockedByBrowser(true);
70
+ setLoadingChat(false);
71
+ }
72
+ }, 10000);
73
+ yield window.embedded_svc.liveAgentAPI.startChat({
74
+ extraPrechatInfo: extraPreChatInfo,
75
+ extraPrechatFormDetails: getChatFormDetails(),
39
76
  });
77
+ clearTimeout(blockedTimeOut);
78
+ setHasBlockedByBrowser(false);
79
+ setChatStart(true);
40
80
  setLoadingChat(false);
41
- };
42
- const initChat = () => {
43
- try {
44
- window.embeddedservice_bootstrap.settings.language = 'en_US';
45
- window.embeddedservice_bootstrap.init(orgId, deploymentDevName, siteURL, { scrt2URL });
46
- }
47
- catch (err) {
48
- console.error('Error loading Enhanced Messaging: ', err);
49
- setChatServiceNotAvailable(true);
50
- setLoadingChat(false);
51
- }
52
- };
53
- window.addEventListener('onEmbeddedMessagingReady', onMessagingReady);
54
- if ((_a = window.embeddedservice_bootstrap) === null || _a === void 0 ? void 0 : _a.prechatAPI) {
55
- onMessagingReady();
56
81
  }
57
- else if (window.embeddedservice_bootstrap) {
58
- initChat();
82
+ catch (e) {
83
+ setLoadingChat(false);
84
+ setHasBlockedByBrowser(true);
59
85
  }
60
- else {
61
- const script = document.createElement('script');
62
- script.src = bootstrapScriptURL;
63
- script.type = 'text/javascript';
64
- script.onload = initChat;
65
- script.onerror = () => {
66
- console.error('Failed to load Enhanced Messaging bootstrap script');
67
- setChatServiceNotAvailable(true);
68
- setLoadingChat(false);
69
- };
70
- document.body.appendChild(script);
86
+ });
87
+ const initEmbedChat = () => {
88
+ const extraPreChatFormDetails = getChatFormDetails();
89
+ try {
90
+ initESW(extraPreChatFormDetails);
71
91
  }
72
- return () => {
73
- window.removeEventListener('onEmbeddedMessagingReady', onMessagingReady);
74
- };
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- }, []);
77
- return { loadingChat, chatServiceNotAvailable, hasBlockedByCookie };
92
+ catch (e) {
93
+ setChatServiceNotAvailable(true);
94
+ console.log(e);
95
+ }
96
+ };
97
+ const initESW = (extraPreChatFormDetails) => {
98
+ window.embedded_svc.settings.displayHelpButton = false; //Or false
99
+ window.embedded_svc.settings.language = 'en'; //For example, enter 'en' or 'en-US'
100
+ window.embedded_svc.settings.enabledFeatures = ['LiveAgent'];
101
+ window.embedded_svc.settings.entryFeature = 'LiveAgent';
102
+ window.embedded_svc.settings.extraPrechatFormDetails = extraPreChatFormDetails;
103
+ window.embedded_svc.settings.extraPrechatInfo = extraPreChatInfo;
104
+ window.embedded_svc.init(host, sandBox, gslbBaseURL, key, appName, extra);
105
+ // Fired when Embedded Service Chat has ended and the application is closed.
106
+ window.embedded_svc.addEventHandler('afterDestroy', function (data) {
107
+ setChatStart(false);
108
+ });
109
+ // if chat didn't initialized after a long wait then we assume
110
+ // chat domains blocked by client network or browser
111
+ const blockedByNetworkTimeOut = setTimeout(() => {
112
+ if (!window.liveAgentDeployment) {
113
+ setHasChatDomainsBlocked(true);
114
+ setLoadingChat(false);
115
+ }
116
+ }, 10000);
117
+ // After loading and setting step is complete we are good to call `bootstrapEmbeddedService`
118
+ window.embedded_svc.addEventHandler('onSettingsCallCompleted', function (data) {
119
+ setLoadingChat(false);
120
+ clearTimeout(blockedByNetworkTimeOut);
121
+ });
122
+ };
123
+ return {
124
+ loadingChat,
125
+ isChatStarted,
126
+ hasBlockedByBrowser,
127
+ hasChatDomainsBlocked,
128
+ initEmbedChat,
129
+ onStartChat,
130
+ chatServiceNotAvailable,
131
+ hasBlockedByCookie,
132
+ getChatFormDetails,
133
+ };
78
134
  };
@@ -0,0 +1,12 @@
1
+ export interface IPreChatFormDetails {
2
+ label: string;
3
+ value: string;
4
+ transcriptFields?: Array<string>;
5
+ displayToAgent: boolean;
6
+ }
7
+ /**
8
+ *
9
+ * The use of this hook is to generate form details based on user current screen
10
+ */
11
+ export declare const usePreChatFormDetails: () => (() => IPreChatFormDetails[]);
12
+ //# sourceMappingURL=usePreChatFormDetails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreChatFormDetails.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePreChatFormDetails.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,QAAO,CAAC,MAAM,mBAAmB,EAAE,CA+CpE,CAAC"}
@@ -0,0 +1,61 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { publicApi } from '@cee-eng/hydrajs';
11
+ import { useContext, useEffect, useState } from 'react';
12
+ import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
13
+ /**
14
+ *
15
+ * The use of this hook is to generate form details based on user current screen
16
+ */
17
+ export const usePreChatFormDetails = () => {
18
+ const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
19
+ const [sessionId, setSessionId] = useState('');
20
+ const loggedInUserRightsData = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data;
21
+ const ssoName = loggedInUserRightsData.getSSOUsername();
22
+ const name = loggedInUserRightsData.getUserFullName();
23
+ const accountNumber = loggedInUserRightsData.getAccountNumber();
24
+ useEffect(() => {
25
+ try {
26
+ const fetchChatSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
27
+ const { message } = yield publicApi.chat.getChatSession();
28
+ setSessionId(message);
29
+ });
30
+ fetchChatSessionId();
31
+ }
32
+ catch (error) {
33
+ console.log('Error', error);
34
+ }
35
+ }, []);
36
+ const getChatFormDetails = () => [
37
+ {
38
+ label: 'SSO Name',
39
+ value: ssoName,
40
+ transcriptFields: ['SSO_Username__c'],
41
+ displayToAgent: true,
42
+ },
43
+ {
44
+ label: 'SessionId',
45
+ value: sessionId,
46
+ transcriptFields: ['SessionId__c'],
47
+ displayToAgent: true,
48
+ },
49
+ {
50
+ label: 'name',
51
+ value: name,
52
+ displayToAgent: true,
53
+ },
54
+ {
55
+ label: 'account',
56
+ value: accountNumber,
57
+ displayToAgent: true,
58
+ },
59
+ ];
60
+ return getChatFormDetails;
61
+ };
@@ -5,6 +5,5 @@ export { GlobalContextWrapper } from './GlobalContextWrapper';
5
5
  export { GlobalMetadataContextProvider, GlobalMetadataStateContext, GlobalMetadataDispatchContext, IGlobalMetadataStateContext, useGlobalDispatchContext, useGlobalStateContext, } from './context/GlobalMetadataContext';
6
6
  export { GlobalTranslationContext, GlobalTranslationProvider, cacheTrans, SELECTED_TRANS_LANGUAGE, } from './context/GlobalTranslationProvider';
7
7
  export { GlobalAlertMessageContextProvider, GlobalAlertMessageStateContext, GlobalAlertMessageDispatchContext, IGlobalAlertMessageStateContext, useGlobalAlertMessageDispatchContext, useGlobalAlertMessageStateContext, } from './context/GlobalAlertMessageContext';
8
- export { CaseStatusContext, CaseStatusProvider } from './context/CaseStatusContext';
9
8
  export * from './utils';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACH,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,iCAAiC,EACjC,8BAA8B,EAC9B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,iCAAiC,GACpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEpF,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACH,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,iCAAiC,EACjC,8BAA8B,EAC9B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,iCAAiC,GACpC,MAAM,qCAAqC,CAAC;AAE7C,cAAc,SAAS,CAAC"}
package/lib/esm/index.js CHANGED
@@ -6,6 +6,4 @@ export { GlobalContextWrapper } from './GlobalContextWrapper';
6
6
  export { GlobalMetadataContextProvider, GlobalMetadataStateContext, GlobalMetadataDispatchContext, useGlobalDispatchContext, useGlobalStateContext, } from './context/GlobalMetadataContext';
7
7
  export { GlobalTranslationContext, GlobalTranslationProvider, cacheTrans, SELECTED_TRANS_LANGUAGE, } from './context/GlobalTranslationProvider';
8
8
  export { GlobalAlertMessageContextProvider, GlobalAlertMessageStateContext, GlobalAlertMessageDispatchContext, useGlobalAlertMessageDispatchContext, useGlobalAlertMessageStateContext, } from './context/GlobalAlertMessageContext';
9
- export { CaseStatusContext, CaseStatusProvider } from './context/CaseStatusContext';
10
9
  export * from './utils';
11
- // dummy change for publish
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalMetadataHelpers.d.ts","sourceRoot":"","sources":["../../../src/reducers/GlobalMetadataHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,EAAE,KAAG,MAAM,EAMjE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,SAAS,EAAE,KAAG,MAAM,EAMvD,CAAC"}
1
+ {"version":3,"file":"GlobalMetadataHelpers.d.ts","sourceRoot":"","sources":["../../../src/reducers/GlobalMetadataHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,EAAE,KAAG,MAAM,EAUjE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,SAAS,EAAE,KAAG,MAAM,EAMvD,CAAC"}
@@ -1,7 +1,11 @@
1
1
  import isEmpty from 'lodash/isEmpty';
2
2
  export const getProcessedCaseTypes = (caseTypes) => {
3
- // Excluding Proactive from Support type options; move Other to the end
4
- caseTypes = caseTypes.filter((caseType) => caseType !== 'Other' && caseType !== 'Proactive');
3
+ // move 'Other' to the end
4
+ caseTypes = caseTypes.filter((caseType) => {
5
+ if (caseType !== 'Other') {
6
+ return caseType;
7
+ }
8
+ });
5
9
  caseTypes.push('Other');
6
10
  return caseTypes;
7
11
  };
@@ -5,9 +5,10 @@ import { IAccount, IPartnerManagedAccount } from '@cee-eng/hydrajs/@types/models
5
5
  import { ISsoContact } from '@cee-eng/hydrajs/@types/models/contact';
6
6
  import { IPreference } from '@cee-eng/hydrajs/@types/models/general';
7
7
  import { IConfigurationResponse } from '@cee-eng/hydrajs/@types/models/maintenance';
8
+ import { ISEProductListParams } from '@cee-eng/hydrajs/@types/models/product';
8
9
  import { IAction, IApiResponseDetails, IPortalJwtToken } from '@rh-support/types/shared';
9
10
  import { UserAuth } from '@rh-support/user-permissions';
10
- import { ApolloQueryClient, IGraphQLAccountResult, ITroubleshootProductResponse } from '@rh-support/utils';
11
+ import { ITroubleshootProductResponse } from '@rh-support/utils';
11
12
  import { MutableRefObject } from 'react';
12
13
  export declare enum UserPreferencesKeys {
13
14
  caseSavedSearchFilters = "PCM-CaseSavedSearchFilters",
@@ -77,8 +78,7 @@ export declare enum GlobalMetadataReducerConstants {
77
78
  setReferrerUrl = "setReferrerUrl",
78
79
  getNoclusteridreasons = "getNoclusteridreasons",
79
80
  setIsSharingHostnameswithRHt = "setIsSharingHostnameswithRHt",
80
- setTraditionalSupportSessionAgreed = "setTraditionalSupportSessionAgreed",
81
- setCaseRecordTypes = "setCaseRecordTypes"
81
+ setCaseListTraditionalSupportAgreed = "setCaseListTraditionalSupportAgreed"
82
82
  }
83
83
  export type ICaseType = string;
84
84
  export type ICaseSeverity = string;
@@ -99,15 +99,12 @@ export interface IBookmarkedGroupIds {
99
99
  namespaceId: number;
100
100
  valueTypeId: number;
101
101
  }
102
- export interface ICaseRecordTypeMap {
103
- [name: string]: string;
104
- }
105
102
  export interface IGlobalMetadataState {
106
103
  allCaseTypes: IApiResponseDetails<ICaseType[]>;
107
104
  allCaseSeverities: IApiResponseDetails<ICaseSeverity[]>;
108
105
  allCaseStatuses: IApiResponseDetails<ICaseStatus[]>;
109
106
  allProducts: IApiResponseDetails<ITroubleshootProductResponse>;
110
- loggedInUsersAccount: IApiResponseDetails<IGraphQLAccountResult>;
107
+ loggedInUsersAccount: IApiResponseDetails<Partial<IAccount>>;
111
108
  loggedInUsersAccountNumber: IApiResponseDetails<string>;
112
109
  loggedInUser: IApiResponseDetails<Partial<ISsoContact>>;
113
110
  loggedInUserJwtToken: Partial<IPortalJwtToken>;
@@ -130,9 +127,7 @@ export interface IGlobalMetadataState {
130
127
  accountCustomEmails: IApiResponseDetails<IAccountNotificationAddresses[]>;
131
128
  referrerUrl: string;
132
129
  caseNoClusterIdReasons: IApiResponseDetails<string[]>;
133
- caseRecordTypes: IApiResponseDetails<ICaseRecordTypeMap>;
134
130
  caseListTraditionalSupportAgreed: boolean;
135
- troubleshootTraditionalSupportAgreed: boolean;
136
131
  }
137
132
  export interface IGlobalMetadataPayloadType extends IGlobalMetadataState {
138
133
  interaction: IIntraction;
@@ -147,48 +142,19 @@ export declare const setReferrerUrl: (dispatch: GlobalMetadataReducerDispatchTyp
147
142
  export declare const removeGroupedBookmarks: (dispatch: GlobalMetadataReducerDispatchType, allBookmarks: IBookmark[], removedAccountsId: number[]) => void;
148
143
  export declare const removeWholeGroup: (dispatch: GlobalMetadataReducerDispatchType, allBookmarks: IBookmark[], rootBookmarIds: number[]) => void;
149
144
  export declare const addEditbookmarks: (dispatch: GlobalMetadataReducerDispatchType, allBookmarks: IBookmark[], updatedAccounts: IBookmarkedAccounts, selectedAccounts: IBookmark[], group: string, accountsRemovedFromGroup?: IBookmark[]) => void;
150
- export declare const fetchCaseTypes: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
151
- query: (options: any) => Promise<any>;
152
- }) => Promise<void>;
153
- export declare const fetchCaseTypesHydra: (dispatch: GlobalMetadataReducerDispatchType, isSecureSupport: boolean) => Promise<void>;
154
- export declare const fetchCaseSeverities: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
155
- query: (options: any) => Promise<any>;
156
- }) => Promise<void>;
157
- export declare const fetchCaseSeveritiesHydra: (dispatch: GlobalMetadataReducerDispatchType, isSecureSupport: boolean) => Promise<void>;
158
- type CaseDetailsDispatch = (action: {
159
- type: string;
160
- payload?: unknown;
161
- }) => void;
162
- type CaseDetailsApolloClient = {
163
- query: (options: any) => Promise<any>;
164
- };
165
- type SetCaseAccountNumberFn = (dispatch: CaseDetailsDispatch, accountNumber: string, isLoggedInUsersAccount?: boolean, loggedInUserAccount?: Partial<IAccount>, apolloClient?: CaseDetailsApolloClient) => Promise<void>;
166
- export declare const fetchCaseDetails: (caseDispatch: CaseDetailsDispatch, apolloClient: CaseDetailsApolloClient, caseNumber: string, setCaseAccountNumber?: SetCaseAccountNumberFn, includeSecureSupport?: boolean) => Promise<{
167
- [x: string]: string | boolean;
168
- }>;
169
- export declare const fetchAllStatuses: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
170
- query: (options: any) => Promise<any>;
171
- }) => Promise<void>;
172
- export declare const fetchProducts: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
173
- query: (options: any) => Promise<any>;
174
- }) => Promise<void>;
175
- export declare const fetchCaseRecordTypes: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
176
- query: (options: any) => Promise<any>;
177
- }) => Promise<import("@rh-support/utils").CaseRecordTypeMap>;
145
+ export declare const fetchCaseTypes: (dispatch: GlobalMetadataReducerDispatchType, isSecureSupport: boolean) => Promise<void>;
146
+ export declare const fetchCaseSeverities: (dispatch: GlobalMetadataReducerDispatchType, isSecureSupport: boolean) => Promise<void>;
147
+ export declare const fetchAllStatuses: (dispatch: GlobalMetadataReducerDispatchType, isSecureSupport: boolean) => Promise<void>;
148
+ export declare const fetchProducts: (dispatch: GlobalMetadataReducerDispatchType, ownerSSOUsername?: string, params?: ISEProductListParams) => Promise<void>;
178
149
  export declare const setAllProducts: (dispatch: GlobalMetadataReducerDispatchType, allProducts: ITroubleshootProductResponse) => void;
179
- export declare const fetchLoggedInUsersAccount: (dispatch: GlobalMetadataReducerDispatchType, token: Partial<IPortalJwtToken>, silent?: boolean, apolloClient?: {
180
- query: (options: any) => Promise<any>;
181
- }) => Promise<IGraphQLAccountResult>;
182
- export declare const fetchLoggedInUser: (dispatch: GlobalMetadataReducerDispatchType, token: Partial<IPortalJwtToken>, pcmConfig: any, apolloClient?: {
183
- query: (options: any) => Promise<any>;
184
- }) => Promise<void>;
185
- export declare const fetchLanguageMetadata: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: {
186
- query: (options: any) => Promise<any>;
187
- }) => Promise<void>;
150
+ export declare const fetchLoggedInUsersAccount: (dispatch: GlobalMetadataReducerDispatchType, token: Partial<IPortalJwtToken>, silent?: boolean) => Promise<IAccount>;
151
+ export declare const fetchLoggedInUser: (dispatch: GlobalMetadataReducerDispatchType, token: Partial<IPortalJwtToken>, pcmConfig: any) => Promise<void>;
152
+ export declare const fetchLanguageMetadata: (dispatch: GlobalMetadataReducerDispatchType) => Promise<void>;
188
153
  export declare const fetchInternalStatusMetadata: (dispatch: GlobalMetadataReducerDispatchType) => Promise<void>;
189
154
  export declare const fetchCaseSbrsMetadata: (dispatch: GlobalMetadataReducerDispatchType) => Promise<void>;
190
- export declare const fetchCaseGroupsForSSO: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: ApolloQueryClient, accountId: string, defaultCaseGroupId?: string | null, contactId?: string, isOrgAdmin?: boolean) => Promise<ICaseGroup[]>;
191
- export declare const fetchCaseGroupsForAccount: (dispatch: GlobalMetadataReducerDispatchType, apolloClient: ApolloQueryClient, accountId: string, defaultCaseGroupId?: string | null, contactId?: string, isOrgAdmin?: boolean) => Promise<ICaseGroup[]>;
155
+ export declare const fetchCaseGroupsForSSO: (dispatch: GlobalMetadataReducerDispatchType, ssoUserName: string) => Promise<ICaseGroup[]>;
156
+ export declare const fetchCaseGroupsForAccount: (dispatch: GlobalMetadataReducerDispatchType, accountNumber: string) => Promise<ICaseGroup[]>;
157
+ export declare const fetchCaseGroups: (dispatch: GlobalMetadataReducerDispatchType) => Promise<void>;
192
158
  export declare const setCaseGroups: (dispatch: GlobalMetadataReducerDispatchType, groups: ICaseGroup[]) => void;
193
159
  export declare const setLoggedInUserJwtToken: (dispatch: GlobalMetadataReducerDispatchType, loggedInUserJwtToken: Partial<IPortalJwtToken>) => void;
194
160
  export declare const loadPCMConfig: (dispatch: GlobalMetadataReducerDispatchType) => Promise<IConfigurationResponse>;
@@ -208,8 +174,7 @@ export declare const updateFeatureFlag: (dispatch: GlobalMetadataReducerDispatch
208
174
  export declare const fetchAccountCustomEmails: (dispatch: GlobalMetadataReducerDispatchType, accountNumber: string) => Promise<void>;
209
175
  export declare const setAccountCustomEmails: (dispatch: GlobalMetadataReducerDispatchType, accountCustomEmails: IAccountNotificationAddresses[]) => void;
210
176
  export declare const fetchNoClusterIdReasonsMetadata: (dispatch: GlobalMetadataReducerDispatchType) => Promise<void>;
211
- /** Sets both case-list and troubleshoot agreement flags together (agree once per session). */
212
- export declare const setTraditionalSupportSessionAgreed: (dispatch: GlobalMetadataReducerDispatchType, value: boolean) => void;
213
- export declare const updateShareHostnameWithRHTState: (dispatch: GlobalMetadataReducerDispatchType, loggedInUsersAccount: IGraphQLAccountResult, shareHostnameWithRHT: boolean) => void;
177
+ export declare const updateCaseListTraditionalSupportAgreed: (dispatch: GlobalMetadataReducerDispatchType, value: boolean) => void;
178
+ export declare const updateShareHostnameWithRHTState: (dispatch: GlobalMetadataReducerDispatchType, loggedInUsersAccount: Partial<IAccount>, shareHostnameWithRHT: boolean) => void;
214
179
  export {};
215
180
  //# sourceMappingURL=GlobalMetadataReducer.d.ts.map