@rh-support/react-context 1.0.15 → 1.0.17

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 (32) hide show
  1. package/lib/esm/GlobalContextWrapper.d.ts +3 -0
  2. package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
  3. package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.d.ts +2 -0
  4. package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.d.ts.map +1 -0
  5. package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.js +9 -0
  6. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +4 -0
  7. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -0
  8. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +37 -0
  9. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +12 -0
  10. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +1 -0
  11. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +29 -0
  12. package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +58 -0
  13. package/lib/esm/components/EmbeddedServiceChat/index.d.ts +2 -0
  14. package/lib/esm/components/EmbeddedServiceChat/index.d.ts.map +1 -0
  15. package/lib/esm/components/EmbeddedServiceChat/index.js +1 -0
  16. package/lib/esm/components/HostnameAwarenessModal/HostnameAwarenessModal.js +1 -1
  17. package/lib/esm/components/index.d.ts +1 -0
  18. package/lib/esm/components/index.d.ts.map +1 -1
  19. package/lib/esm/components/index.js +1 -0
  20. package/lib/esm/hooks/index.d.ts +3 -0
  21. package/lib/esm/hooks/index.d.ts.map +1 -1
  22. package/lib/esm/hooks/index.js +3 -0
  23. package/lib/esm/hooks/useChatConfig.d.ts +20 -0
  24. package/lib/esm/hooks/useChatConfig.d.ts.map +1 -0
  25. package/lib/esm/hooks/useChatConfig.js +58 -0
  26. package/lib/esm/hooks/useChatInit.d.ts +17 -0
  27. package/lib/esm/hooks/useChatInit.d.ts.map +1 -0
  28. package/lib/esm/hooks/useChatInit.js +85 -0
  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 +78 -0
  32. package/package.json +9 -6
@@ -9,6 +9,9 @@ declare global {
9
9
  portal: any;
10
10
  Raven: any;
11
11
  chrometwo_ready: any;
12
+ embedded_svc: any;
13
+ $Lightning: any;
14
+ liveAgentDeployment: any;
12
15
  }
13
16
  interface Document {
14
17
  documentMode: any;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,OAAA,KAAK,GAAG,KAAK,GAAG,CAAC;QAC9E,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,eAAe,EAAE,GAAG,CAAC;KACxB;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA6FD,eAAO,MAAM,oBAAoB,UAAW,MAAM,gBAKjD,CAAC"}
1
+ {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,OAAA,KAAK,GAAG,KAAK,GAAG,CAAC;QAC9E,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,eAAe,EAAE,GAAG,CAAC;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB,UAAU,EAAE,GAAG,CAAC;QAChB,mBAAmB,EAAE,GAAG,CAAC;KAC5B;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA6FD,eAAO,MAAM,oBAAoB,UAAW,MAAM,gBAKjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const ChatSVGIcon: () => JSX.Element;
2
+ //# sourceMappingURL=ChatSVGIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSVGIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ChatSVGIcon.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,mBAwBvB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export const ChatSVGIcon = () => {
3
+ return (React.createElement("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink" },
4
+ React.createElement("rect", { width: "36", height: "36", fill: "url(#pattern0)" }),
5
+ React.createElement("defs", null,
6
+ React.createElement("pattern", { id: "pattern0", patternContentUnits: "objectBoundingBox", width: "1", height: "1" },
7
+ React.createElement("use", { xlinkHref: "#image0_726_235", transform: "scale(0.00277778)" })),
8
+ React.createElement("image", { id: "image0_726_235", width: "360", height: "360", xlinkHref: "data:image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87NUxK7PcDa1d2qcPcwYNPMkjzqTfGvHDCDTwZEdE+mZo7daIH0aggZOYI/1quoTxldebvvZq/h4O5Bo0cHJjrdNK3xd/vO7Q2iejfDyBBgjlEgdAKIEGCCXQAKEEGiCUQAOEEmiAUAINEEqgAUIJNEAogQYIJdAAoQQaIJRAA4QSaIBQAg0QSqABQgk0QCiBBggl0AChBBoglEADhBJogFACDRBKoAFCCTRAKIEGCCXQAKEEGiCUQAOEEmiAUAINEEqgAUIJNEAogQYIJdAAoQQaIJRAA4QSaIBQAg0QSqABQgk0QCiBBggl0AChBBoglEADhBJogFACDRBKoAFCCTRAKIEGCCXQAKEEGiBRKeU/zxSMin2RnsUAAAAASUVORK5CYII=" }))));
9
+ };
@@ -0,0 +1,4 @@
1
+ import './embeddedServiceChat.css';
2
+ import { FC } from 'react';
3
+ export declare const EmbeddedServiceChat: FC;
4
+ //# sourceMappingURL=EmbeddedServiceChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAMvD,eAAO,MAAM,mBAAmB,EAAE,EAwEjC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import './embeddedServiceChat.css';
2
+ import { Button, ButtonVariant, Popover, PopoverPosition, Spinner } from '@patternfly/react-core';
3
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
4
+ import React, { useEffect, useState } from 'react';
5
+ import { Trans, useTranslation } from 'react-i18next';
6
+ import { useChatInit } from '../..';
7
+ import { ChatSVGIcon } from './ChatSVGIcon';
8
+ export const EmbeddedServiceChat = () => {
9
+ const { loadingChat, isChatStarted, initEmbedChat, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser } = useChatInit();
10
+ const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
11
+ const { t } = useTranslation();
12
+ const shouldClose = () => {
13
+ setIsBlockedErrorBoxVisible(false);
14
+ };
15
+ const shouldOpen = () => {
16
+ setIsBlockedErrorBoxVisible(true);
17
+ };
18
+ const chatErrorMessagePopover = () => (React.createElement("div", { className: "chatButton chatError", id: "chat-blocked-popover-selector" },
19
+ React.createElement(Popover, { "aria-label": t('Cannot connect to chat support'), alertSeverityVariant: 'danger', position: PopoverPosition.top, hasAutoWidth: true, headerIcon: React.createElement(ExclamationCircleIcon, { className: "pf-u-danger-color-100" }), headerComponent: "h1", headerContent: React.createElement(Trans, null, "Cannot connect to chat support"), bodyContent: React.createElement("p", { className: "pf-u-px-md" },
20
+ React.createElement(Trans, null, "There are multiple problems that can cause this error."),
21
+ React.createElement("br", null),
22
+ React.createElement("a", { href: `https://access.redhat.com/articles/313583#${hasBlockedByBrowser
23
+ ? 'troubleshoot_browser'
24
+ : hasChatDomainsBlocked
25
+ ? 'troubleshoot_network'
26
+ : ''}`, target: "_blank", rel: "noreferrer noopener" },
27
+ React.createElement(Trans, null, "See a list of possible causes."))), isVisible: isBlockedErrorBoxVisible, shouldClose: shouldClose, shouldOpen: shouldOpen },
28
+ React.createElement(Button, { variant: ButtonVariant.link, className: "pf-u-m-0 pf-u-p-0" },
29
+ React.createElement(ChatSVGIcon, null)))));
30
+ useEffect(() => {
31
+ initEmbedChat();
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, []);
34
+ return loadingChat ? (React.createElement("div", { className: "chatButton" },
35
+ React.createElement(Spinner, { isSVG: true, diameter: "28px", className: "pf-u-m-xs" }))) : hasBlockedByBrowser || hasChatDomainsBlocked ? (chatErrorMessagePopover()) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: onStartChat, "data-tracking-id": "embedded-service-chat" },
36
+ React.createElement(ChatSVGIcon, null))) : (React.createElement(React.Fragment, null));
37
+ };
@@ -0,0 +1,12 @@
1
+ export declare const extraPreChatInfo: {
2
+ entityFieldMaps: {
3
+ doCreate: boolean;
4
+ doFind: boolean;
5
+ fieldName: string;
6
+ isExactMatch: boolean;
7
+ label: string;
8
+ }[];
9
+ entityName: string;
10
+ saveToTranscript: string;
11
+ }[];
12
+ //# sourceMappingURL=ExtraPreChatInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtraPreChatInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ExtraPreChatInfo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;GA6B5B,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const extraPreChatInfo = [
2
+ {
3
+ entityFieldMaps: [
4
+ {
5
+ doCreate: false,
6
+ doFind: true,
7
+ fieldName: 'SSO_Username__c',
8
+ isExactMatch: true,
9
+ label: 'SSO Name',
10
+ },
11
+ {
12
+ doCreate: false,
13
+ doFind: true,
14
+ fieldName: 'ContactSessionId__c',
15
+ isExactMatch: false,
16
+ label: 'SessionId',
17
+ },
18
+ {
19
+ doCreate: false,
20
+ doFind: true,
21
+ fieldName: 'Account',
22
+ isExactMatch: true,
23
+ label: 'account',
24
+ },
25
+ ],
26
+ entityName: '',
27
+ saveToTranscript: 'SSO_Username__c',
28
+ },
29
+ ];
@@ -0,0 +1,58 @@
1
+ .chatButton {
2
+ position: fixed;
3
+ right: 4rem;
4
+ bottom: 1rem;
5
+ background: #ffffff;
6
+ box-shadow: 0px 2px 3px rgb(0 0 0 / 15%);
7
+ border-radius: 3px;
8
+ cursor: pointer;
9
+ padding: 4px;
10
+ width: 44px;
11
+ height: 44px;
12
+ }
13
+
14
+ .chatError {
15
+ opacity: 0.7;
16
+ }
17
+
18
+ /* Requested by CCM team */
19
+ .agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
20
+ text-align: left;
21
+ }
22
+
23
+ /* Adding fowling CSS as requested by CCM team (Sudhir Panda) */
24
+ .embeddedServiceLiveAgentStateChat .chatSessionStartTime {
25
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
26
+ }
27
+ .embeddedServiceLiveAgentStateChatItem.chatMessage {
28
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
29
+ }
30
+ .embeddedServiceLiveAgentStateChatItem.chatMessage button {
31
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
32
+ }
33
+ .embeddedServiceHelpButton .helpButton .uiButton {
34
+ background-color: #005290;
35
+ font-family: 'Arial', sans-serif;
36
+ }
37
+ .embeddedServiceHelpButton .helpButton .uiButton:focus {
38
+ outline: 1px solid #005290;
39
+ }
40
+ .agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
41
+ text-align: left;
42
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
43
+ }
44
+ /* red hat chat icon */
45
+ .embeddedServiceLiveAgentStateChatAvatar.isLightningOutContext .agentIconColor0 {
46
+ background-image: url('https://access.redhat.com/chrome_themes/nimbus/img/red-hat-customer-portal.svg');
47
+ background-repeat: no-repeat;
48
+ background-size: 420% !important;
49
+ font-size: 0 !important;
50
+ background-color: #fff !important;
51
+ }
52
+
53
+ /* user chat bubble */
54
+ .chasitor.chat-content[CLWCP-lwcchatpack_lwcchatpack] {
55
+ background: #fff !important;
56
+ color: #0066cc !important;
57
+ border: #0066cc 1px solid !important;
58
+ }
@@ -0,0 +1,2 @@
1
+ export * from './EmbeddedServiceChat';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './EmbeddedServiceChat';
@@ -113,7 +113,7 @@ export const HostnameAwarenessModal = () => {
113
113
  isLoadingHostnamesVisibilityObj ||
114
114
  !canUseHostName ||
115
115
  alreadyCheckedCloseModal ||
116
- originalViewedCountValue > 8 ||
116
+ originalViewedCountValue > 2 ||
117
117
  (doNotShowModal === 1 && doNotShowNotClicked)) {
118
118
  return React.createElement(React.Fragment, null);
119
119
  }
@@ -4,4 +4,5 @@ export * from './AccountSelector';
4
4
  export * from './NewFeatureAnnouncement';
5
5
  export * from './SharedModals';
6
6
  export * from './HostnameAwarenessModal';
7
+ export * from './EmbeddedServiceChat';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
@@ -4,3 +4,4 @@ export * from './AccountSelector';
4
4
  export * from './NewFeatureAnnouncement';
5
5
  export * from './SharedModals';
6
6
  export * from './HostnameAwarenessModal';
7
+ export * from './EmbeddedServiceChat';
@@ -5,4 +5,7 @@ export * from './useSubscriptionAbused';
5
5
  export * from './useCanEditCase';
6
6
  export * from './useCanCreateCase';
7
7
  export * from './useUserPreferences';
8
+ export * from './useChatInit';
9
+ export * from './usePreChatFormDetails';
10
+ export * from './useChatConfig';
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
@@ -5,3 +5,6 @@ export * from './useSubscriptionAbused';
5
5
  export * from './useCanEditCase';
6
6
  export * from './useCanCreateCase';
7
7
  export * from './useUserPreferences';
8
+ export * from './useChatInit';
9
+ export * from './usePreChatFormDetails';
10
+ export * from './useChatConfig';
@@ -0,0 +1,20 @@
1
+ /**
2
+ *
3
+ * This hook is used for selected chat configuration based on environment
4
+ */
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
+ };
20
+ //# sourceMappingURL=useChatConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAoDzB,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { Env } from '@cee-eng/hydrajs';
2
+ /**
3
+ *
4
+ * This hook is used for selected chat configuration based on environment
5
+ */
6
+ export const useChatConfig = () => {
7
+ const env = Env.getEnvName();
8
+ switch (env) {
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: '00D7j0000008oSo',
15
+ appName: 'RedHatChatBot',
16
+ extra: {
17
+ baseLiveAgentContentURL: 'https://c.la3-c1cs-ia5.salesforceliveagent.com/content',
18
+ deploymentId: '5727j0000004CqR',
19
+ buttonId: '5737j0000004CKB',
20
+ baseLiveAgentURL: 'https://d.la3-c1cs-ia5.salesforceliveagent.com/chat',
21
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I7j000000CadEEAS_180b2280b37',
22
+ isOfflineSupportEnabled: false,
23
+ },
24
+ };
25
+ case Env.EnvNames.STAGE:
26
+ return {
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: '00Df0000003f0P8',
31
+ appName: 'RedHatChatBot',
32
+ extra: {
33
+ baseLiveAgentContentURL: 'https://c.la1-c1cs-ia7.salesforceliveagent.com/content',
34
+ deploymentId: '572f00000008QON',
35
+ buttonId: '573f00000008QWv',
36
+ baseLiveAgentURL: 'https://d.la1-c1cs-ia7.salesforceliveagent.com/chat',
37
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04If00000004CPqEAM_180cd4fc482',
38
+ isOfflineSupportEnabled: false,
39
+ },
40
+ };
41
+ default:
42
+ return {
43
+ host: 'https://gss--qa.my.salesforce.com',
44
+ sandBox: 'https://qa-gssdex.cs203.force.com/botchat',
45
+ gslbBaseURL: 'https://service.force.com',
46
+ key: '00D7j0000008oSo',
47
+ appName: 'RedHatChatBot',
48
+ extra: {
49
+ baseLiveAgentContentURL: 'https://c.la3-c1cs-ia4.salesforceliveagent.com/content',
50
+ deploymentId: '5727j0000004CqR',
51
+ buttonId: '5737j0000004CKB',
52
+ baseLiveAgentURL: 'https://d.la3-c1cs-ia4.salesforceliveagent.com/chat',
53
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I7j000000CadEEAS_180b2280b37',
54
+ isOfflineSupportEnabled: false,
55
+ },
56
+ };
57
+ }
58
+ };
@@ -0,0 +1,17 @@
1
+ interface IChatOptions {
2
+ loadingChat: boolean;
3
+ isChatStarted: boolean;
4
+ hasBlockedByBrowser: boolean;
5
+ hasChatDomainsBlocked: boolean;
6
+ initEmbedChat: () => void;
7
+ onStartChat: () => void;
8
+ }
9
+ /**
10
+ * This hook is used for setting chat up and listing custom event of chat.
11
+ * for more details https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm
12
+ * @param initialState
13
+ * @returns
14
+ */
15
+ export declare const useChatInit: (initialState?: boolean) => IChatOptions;
16
+ export {};
17
+ //# sourceMappingURL=useChatInit.d.ts.map
@@ -0,0 +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,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;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,YA6E3D,CAAC"}
@@ -0,0 +1,85 @@
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 { useState } from 'react';
11
+ import { extraPreChatInfo } from '../components/EmbeddedServiceChat/ExtraPreChatInfo';
12
+ import { useChatConfig } from './useChatConfig';
13
+ import { usePreChatFormDetails } from './usePreChatFormDetails';
14
+ /**
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
19
+ */
20
+ export const useChatInit = (initialState = false) => {
21
+ const [isChatStarted, setChatStart] = useState(initialState);
22
+ // Need to set loading status true as it will prevent starting chat before loading necessary dependencies
23
+ const [loadingChat, setLoadingChat] = useState(true);
24
+ const [hasBlockedByBrowser, setHasBlockedByBrowser] = useState(false);
25
+ const [hasChatDomainsBlocked, setHasChatDomainsBlocked] = useState(false);
26
+ const getChatFormDetails = usePreChatFormDetails();
27
+ const { host, sandBox, gslbBaseURL, key, appName, extra } = useChatConfig();
28
+ const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
29
+ setLoadingChat(true);
30
+ // if chat didn't start after a long wait
31
+ // then we assume browser has blocked the script
32
+ const blockedTimeOut = setTimeout(() => {
33
+ if (!window.$Lightning) {
34
+ setHasBlockedByBrowser(true);
35
+ setLoadingChat(false);
36
+ }
37
+ }, 10000);
38
+ yield window.embedded_svc.liveAgentAPI.startChat({
39
+ extraPrechatInfo: extraPreChatInfo,
40
+ extraPrechatFormDetails: getChatFormDetails(),
41
+ });
42
+ clearTimeout(blockedTimeOut);
43
+ setHasBlockedByBrowser(false);
44
+ setChatStart(true);
45
+ setLoadingChat(false);
46
+ });
47
+ const initEmbedChat = () => {
48
+ const extraPreChatFormDetails = getChatFormDetails();
49
+ initESW(extraPreChatFormDetails);
50
+ };
51
+ const initESW = (extraPreChatFormDetails) => {
52
+ window.embedded_svc.settings.displayHelpButton = false; //Or false
53
+ window.embedded_svc.settings.language = 'en'; //For example, enter 'en' or 'en-US'
54
+ window.embedded_svc.settings.enabledFeatures = ['LiveAgent'];
55
+ window.embedded_svc.settings.entryFeature = 'LiveAgent';
56
+ window.embedded_svc.settings.extraPrechatFormDetails = extraPreChatFormDetails;
57
+ window.embedded_svc.settings.extraPrechatInfo = extraPreChatInfo;
58
+ window.embedded_svc.init(host, sandBox, gslbBaseURL, key, appName, extra);
59
+ // Fired when Embedded Service Chat has ended and the application is closed.
60
+ window.embedded_svc.addEventHandler('afterDestroy', function (data) {
61
+ setChatStart(false);
62
+ });
63
+ // if chat didn't initialized after a long wait then we assume
64
+ // chat domains blocked by client network or browser
65
+ const blockedByNetworkTimeOut = setTimeout(() => {
66
+ if (!window.liveAgentDeployment) {
67
+ setHasChatDomainsBlocked(true);
68
+ setLoadingChat(false);
69
+ }
70
+ }, 10000);
71
+ // After loading and setting step is complete we are good to call `bootstrapEmbeddedService`
72
+ window.embedded_svc.addEventHandler('onSettingsCallCompleted', function (data) {
73
+ setLoadingChat(false);
74
+ clearTimeout(blockedByNetworkTimeOut);
75
+ });
76
+ };
77
+ return {
78
+ loadingChat,
79
+ isChatStarted,
80
+ hasChatDomainsBlocked,
81
+ hasBlockedByBrowser,
82
+ initEmbedChat,
83
+ onStartChat,
84
+ };
85
+ };
@@ -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":"AAOA,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,CA6DpE,CAAC"}
@@ -0,0 +1,78 @@
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 { isValidCaseNumber } from '@rh-support/utils';
12
+ import { useContext, useEffect, useState } from 'react';
13
+ import { useRouteMatch } from 'react-router-dom';
14
+ import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
15
+ /**
16
+ *
17
+ * The use of this hook is to generate form details based on user current screen
18
+ */
19
+ export const usePreChatFormDetails = () => {
20
+ var _a;
21
+ const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
22
+ const [sessionId, setSessionId] = useState('');
23
+ const loggedInUserRightsData = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data;
24
+ const ssoName = loggedInUserRightsData.getSSOUsername();
25
+ const name = loggedInUserRightsData.getUserFullName();
26
+ const accountNumber = loggedInUserRightsData.getAccountNumber();
27
+ const match = useRouteMatch('/case/:caseNumber');
28
+ const caseNumber = (_a = match === null || match === void 0 ? void 0 : match.params) === null || _a === void 0 ? void 0 : _a.caseNumber;
29
+ const isCaseDetailsPage = isValidCaseNumber(caseNumber);
30
+ const currentCaseNumber = isCaseDetailsPage ? caseNumber : undefined;
31
+ useEffect(() => {
32
+ try {
33
+ const fetchChatSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
34
+ const { message } = yield publicApi.chat.getChatSession();
35
+ setSessionId(message);
36
+ });
37
+ fetchChatSessionId();
38
+ }
39
+ catch (error) {
40
+ console.log('Error', error);
41
+ }
42
+ }, []);
43
+ const getChatFormDetails = () => [
44
+ {
45
+ label: 'SSO Name',
46
+ value: ssoName,
47
+ transcriptFields: ['SSO_Username__c'],
48
+ displayToAgent: true,
49
+ },
50
+ {
51
+ label: 'SessionId',
52
+ value: sessionId,
53
+ transcriptFields: ['SessionId__c'],
54
+ displayToAgent: true,
55
+ },
56
+ {
57
+ label: 'name',
58
+ value: name,
59
+ displayToAgent: true,
60
+ },
61
+ {
62
+ label: 'account',
63
+ value: accountNumber,
64
+ displayToAgent: true,
65
+ },
66
+ ...(currentCaseNumber
67
+ ? [
68
+ {
69
+ label: 'currentCaseNumber',
70
+ transcriptFields: ['CaseNumber__c'],
71
+ value: currentCaseNumber,
72
+ displayToAgent: true,
73
+ },
74
+ ]
75
+ : []),
76
+ ];
77
+ return getChatFormDetails;
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -44,16 +44,17 @@
44
44
  "@cee-eng/hydrajs": "4.14.53",
45
45
  "@patternfly/react-core": "4.264.0",
46
46
  "@patternfly/react-icons": "4.92.10",
47
- "@rh-support/components": "1.2.13",
47
+ "@rh-support/components": "1.2.14",
48
48
  "@rh-support/types": "0.2.0",
49
- "@rh-support/user-permissions": "1.0.10",
50
- "@rh-support/utils": "1.0.8",
49
+ "@rh-support/user-permissions": "1.0.11",
50
+ "@rh-support/utils": "1.0.9",
51
51
  "i18next": "^19.0.1",
52
52
  "localforage": "^1.7.3",
53
53
  "lodash": "^4.17.21",
54
54
  "react": "17.0.2",
55
55
  "react-dom": "17.0.2",
56
56
  "react-i18next": "^11.2.5",
57
+ "react-router-dom": "^5.1.2",
57
58
  "react-test-renderer": "^16.9.0"
58
59
  },
59
60
  "devDependencies": {
@@ -64,7 +65,9 @@
64
65
  "@types/i18next": "^12.1.0",
65
66
  "@types/lodash": "^4.14.136",
66
67
  "@types/react": "^17.0.14",
67
- "@types/react-i18next": "^8.1.0"
68
+ "@types/react-i18next": "^8.1.0",
69
+ "@types/react-router-dom": "^5.1.2",
70
+ "history": "4.10.1"
68
71
  },
69
72
  "scripts": {
70
73
  "build:watch": "../../node_modules/.bin/tsc -w -p config/tsconfig.json & npm run watch:css",
@@ -87,5 +90,5 @@
87
90
  "not ie <= 11",
88
91
  "not op_mini all"
89
92
  ],
90
- "gitHead": "8e9b0b138cec4a9e71180e96ee391702b6754236"
93
+ "gitHead": "627d7c3613245cf973dff8bee155a6f6fbe56686"
91
94
  }