@rh-support/react-context 2.5.275 → 2.5.276

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 (29) 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 +3 -9
  4. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts +2 -0
  5. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts.map +1 -1
  6. package/lib/esm/components/AccountSelector/AccountSelectorInternal.js +35 -89
  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 -16
  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 -0
  14. package/lib/esm/hooks/index.d.ts +1 -0
  15. package/lib/esm/hooks/index.d.ts.map +1 -1
  16. package/lib/esm/hooks/index.js +1 -0
  17. package/lib/esm/hooks/useChatConfig.d.ts +17 -9
  18. package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
  19. package/lib/esm/hooks/useChatConfig.js +43 -11
  20. package/lib/esm/hooks/useChatInit.d.ts +13 -9
  21. package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
  22. package/lib/esm/hooks/useChatInit.js +119 -59
  23. package/lib/esm/hooks/usePreChatFormDetails.d.ts +12 -0
  24. package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +1 -0
  25. package/lib/esm/hooks/usePreChatFormDetails.js +61 -0
  26. package/lib/esm/reducers/GlobalMetadataReducer.d.ts +8 -38
  27. package/lib/esm/reducers/GlobalMetadataReducer.d.ts.map +1 -1
  28. package/lib/esm/reducers/GlobalMetadataReducer.js +35 -168
  29. package/package.json +5 -5
@@ -8,7 +8,9 @@ declare global {
8
8
  MSInputMethodContext: any;
9
9
  portal: any;
10
10
  Raven: any;
11
- embeddedservice_bootstrap: any;
11
+ embedded_svc: any;
12
+ $Lightning: any;
13
+ liveAgentDeployment: any;
12
14
  }
13
15
  interface Document {
14
16
  documentMode: any;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAenD,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,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,yBAAyB,EAAE,GAAG,CAAC;KAClC;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA2GD,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,sBAKjD,CAAC"}
1
+ {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,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,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,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;AAmGD,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,sBAKjD,CAAC"}
@@ -7,19 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { useApolloClient } from '@apollo/client/react';
11
10
  import { accounts, Config } from '@cee-eng/hydrajs';
12
11
  import { LoginModal } from '@rh-support/components';
13
- import { fetchAndSetSalesforceToken, getApiResourceObject, setSecuredSupport, setStrataHeaders, } from '@rh-support/utils';
12
+ import { getApiResourceObject, setSecuredSupport, setStrataHeaders } from '@rh-support/utils';
14
13
  import isEmpty from 'lodash/isEmpty';
15
14
  import React, { useEffect, useState } from 'react';
16
15
  import { GlobalMetadataContextProvider, GlobalMetadataDispatchContext } from './context/GlobalMetadataContext';
17
- import { fetchAccountManagers, fetchCaseRecordTypes, fetchLoggedInUser, fetchLoggedInUsersAccount, fetchManagedAccounts, fetchUserPreferences, GlobalMetadataReducerConstants, loadPCMConfig, setLoggedInUserJwtToken, } from './reducers/GlobalMetadataReducer';
16
+ import { fetchAccountManagers, fetchLoggedInUser, fetchLoggedInUsersAccount, fetchManagedAccounts, fetchUserPreferences, GlobalMetadataReducerConstants, loadPCMConfig, setLoggedInUserJwtToken, } from './reducers/GlobalMetadataReducer';
18
17
  function GlobalContextMetadataWrapper() {
19
18
  const [showReLoginModal, setShowReLoginModal] = useState(false);
20
19
  const [showSessionExpiredModal, setShowSessionExpiredModal] = useState(false);
21
20
  const dispatchToGlobalMetadataReducer = React.useContext(GlobalMetadataDispatchContext);
22
- const apolloClient = useApolloClient();
23
21
  // Configuring callbacks to show modals in case of auth logout or session expiry
24
22
  useEffect(() => {
25
23
  const init = () => __awaiter(this, void 0, void 0, function* () {
@@ -31,15 +29,11 @@ function GlobalContextMetadataWrapper() {
31
29
  setShowSessionExpiredModal(true);
32
30
  }
33
31
  }));
34
- session.on('AuthRefreshSuccess', () => {
35
- fetchAndSetSalesforceToken(window.sessionjs.getEncodedToken());
36
- });
37
32
  });
38
33
  init();
39
34
  }, []);
40
35
  const loadGlobalMetadata = (loggedInUserJwtToken) => {
41
36
  setLoggedInUserJwtToken(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
42
- fetchCaseRecordTypes(dispatchToGlobalMetadataReducer, apolloClient);
43
37
  /**
44
38
  * Even GS4 users can use strata's normal user and account endpoints and thus fetching them before hand. This improves the load time by 4 seconds
45
39
  */
@@ -49,7 +43,7 @@ function GlobalContextMetadataWrapper() {
49
43
  fetchUserPreferences(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
50
44
  fetchManagedAccounts(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
51
45
  fetchAccountManagers(dispatchToGlobalMetadataReducer, loggedInUserJwtToken);
52
- fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, false, apolloClient).then((loggedInUserAccount) => {
46
+ fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken).then((loggedInUserAccount) => {
53
47
  setSecuredSupport(loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport);
54
48
  if (loggedInUserAccount === null || loggedInUserAccount === void 0 ? void 0 : loggedInUserAccount.secureSupport) {
55
49
  Config.setUserConfig({ isLoggedInAccountGS4: true });
@@ -1,4 +1,5 @@
1
1
  import { IAccount } from '@cee-eng/hydrajs/@types/models/account';
2
+ import { IAccountListParams } from '@cee-eng/hydrajs/@types/models/csp/account';
2
3
  import React from 'react';
3
4
  interface IProps {
4
5
  selectedAccounts?: IAccount[];
@@ -7,6 +8,7 @@ interface IProps {
7
8
  canBookmarkAccount?: boolean;
8
9
  suggestBookmarkAccounts?: boolean;
9
10
  onSelect?: (accounts: IAccount[]) => any;
11
+ accountListParams?: IAccountListParams;
10
12
  multiple?: boolean;
11
13
  isInValid?: boolean;
12
14
  restrictedOnSubscriptionAbuse?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AA2BlE,OAAO,KAA4D,MAAM,OAAO,CAAC;AAKjF,UAAU,MAAM;IACZ,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,qBAyW7C;kBAzWQ,uBAAuB;;;AA4WhC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAqBhF,OAAO,KAA+C,MAAM,OAAO,CAAC;AAKpE,UAAU,MAAM;IACZ,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,qBA+S7C;kBA/SQ,uBAAuB;;;AAkThC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -7,19 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { useApolloClient } from '@apollo/client/react';
10
+ import { accounts } from '@cee-eng/hydrajs';
11
11
  import { Button, Flex, FlexItem, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
12
+ import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
12
13
  import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-icon';
13
- import { LoadingIndicator } from '@rh-support/components';
14
- import { buildSearchAccountsWhere, handleGraphQLSearchAccountsResponse, SEARCH_ACCOUNTS, } from '@rh-support/utils';
15
- import debounce from 'lodash/debounce';
14
+ import { LoadingIndicator, useFetch } from '@rh-support/components';
16
15
  import isEmpty from 'lodash/isEmpty';
17
16
  import isNull from 'lodash/isNull';
18
17
  import isUndefined from 'lodash/isUndefined';
19
18
  import uniqBy from 'lodash/uniqBy';
20
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
21
20
  import { Trans, useTranslation } from 'react-i18next';
22
- import { sortAccountsByQuery } from '../../utils';
21
+ import { parseAccountSearchQuery, sortAccountsByQuery } from '../../utils';
23
22
  const defaultProps = {
24
23
  id: '',
25
24
  className: '',
@@ -51,28 +50,24 @@ const getDisplayName = (account) => {
51
50
  : '';
52
51
  };
53
52
  function AccountSelectorInternal(props) {
54
- const apolloClient = useApolloClient();
53
+ const { request, isFetching } = useFetch(accounts.getAccounts, { isAbortable: true });
55
54
  const [items, setItems] = useState([]);
56
55
  const [selectedItems, setSelectedItems] = useState([]);
57
56
  const [isOpen, setIsOpen] = useState(false);
58
57
  const [isQueryChanged, setIsQueryChanged] = useState(false);
59
- const [isFetching, setIsFetching] = useState(false);
60
58
  const [query, setQuery] = useState('');
61
59
  const [focusedItemIndex, setFocusedItemIndex] = useState(null);
62
- const [hasNextPage, setHasNextPage] = useState(false);
63
- const [endCursor, setEndCursor] = useState('');
64
- const [currentSearchQuery, setCurrentSearchQuery] = useState('');
65
60
  const textInputRef = useRef();
66
61
  const inputGroupRef = useRef();
67
- const abortControllerRef = useRef();
68
62
  const { t } = useTranslation();
69
63
  const bookmarkedAccountsDeduped = uniqBy(props.bookmarkedAccounts, (b) => b.accountNumber);
70
64
  const pageSize = 20;
65
+ const [resultSize, setResultSize] = useState(pageSize);
71
66
  const setQueryLabel = (selectedItems) => {
72
67
  const item = !isEmpty(selectedItems) && !props.multiple ? selectedItems[0] : {};
73
68
  setQuery(getDisplayName(item));
74
69
  };
75
- const itemsToRender = useMemo(() => (isEmpty(items) ? bookmarkedAccountsDeduped : items), [items, bookmarkedAccountsDeduped]);
70
+ const itemsToRender = useMemo(() => (isEmpty(items) ? bookmarkedAccountsDeduped : items.slice(0, props.paginate ? resultSize : items.length)), [items, bookmarkedAccountsDeduped, props.paginate, resultSize]);
76
71
  useEffect(() => {
77
72
  if (!props.multiple) {
78
73
  const selectedItem = (props.selectedAccounts || [])[0];
@@ -86,13 +81,11 @@ function AccountSelectorInternal(props) {
86
81
  setQueryLabel(selectedItems);
87
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
83
  }, [selectedItems, props.multiple]);
89
- const onDisplayMoreClick = (e) => __awaiter(this, void 0, void 0, function* () {
84
+ const onDisplayMoreClick = (e) => {
90
85
  e.stopPropagation();
86
+ setResultSize((pre) => Math.min(pre + pageSize, items.length));
91
87
  setIsOpen(true);
92
- if (!hasNextPage || !endCursor || !currentSearchQuery)
93
- return;
94
- yield fetchAccounts(currentSearchQuery, endCursor);
95
- });
88
+ };
96
89
  const dropdownOptions = useMemo(() => {
97
90
  if (isFetching) {
98
91
  return (React.createElement("div", { key: "searching", className: "pf-v6-u-px-md pf-v6-u-py-sm" },
@@ -103,9 +96,13 @@ function AccountSelectorInternal(props) {
103
96
  React.createElement(Trans, null, "No results found")));
104
97
  }
105
98
  return [
106
- ...itemsToRender.map((item, index) => (React.createElement(SelectOption, { isFocused: focusedItemIndex === index, key: index, value: item, hasCheckbox: props.multiple, isSelected: selectedItems.some((account) => item.accountNumber === account.accountNumber) },
107
- React.createElement("span", null, getDisplayName(item))))),
108
- ...(hasNextPage
99
+ ...itemsToRender.map((item, index) => (React.createElement(SelectOption, { isFocused: focusedItemIndex === index, key: index, value: item, hasCheckbox: props.multiple, isSelected: selectedItems.some((account) => item.accountNumber === account.accountNumber) }, props.restrictedOnSubscriptionAbuse && item.subscriptionAbuse ? (React.createElement(Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
100
+ React.createElement(FlexItem, { className: "form-instructions form-invalid" }, getDisplayName(item)),
101
+ React.createElement(FlexItem, { className: "form-instructions form-invalid pf-v6-u-text-nowrap pf-v6-u-pr-sm" },
102
+ React.createElement(InfoCircleIcon, null),
103
+ " ",
104
+ React.createElement(Trans, null, "Subscription abuse")))) : (React.createElement("span", null, getDisplayName(item)))))),
105
+ ...(resultSize < items.length
109
106
  ? [
110
107
  React.createElement("div", { className: "pf-v6-c-divider", role: "separator", key: "separator" }),
111
108
  React.createElement(SelectOption, { key: 'diplay-more-option', onClick: onDisplayMoreClick, value: 'display-more' },
@@ -118,62 +115,18 @@ function AccountSelectorInternal(props) {
118
115
  },
119
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
120
117
  [items, bookmarkedAccountsDeduped, isFetching, itemsToRender, isQueryChanged]);
121
- const fetchAccounts = useCallback((searchQuery, afterCursor) => __awaiter(this, void 0, void 0, function* () {
122
- if (isEmpty(searchQuery)) {
118
+ const fetchAccounts = (rawQuery) => __awaiter(this, void 0, void 0, function* () {
119
+ if (isEmpty(rawQuery === null || rawQuery === void 0 ? void 0 : rawQuery.trim())) {
123
120
  return;
124
121
  }
125
- if (abortControllerRef.current) {
126
- abortControllerRef.current.abort();
127
- }
128
- abortControllerRef.current = new AbortController();
129
- const isAppending = !!afterCursor;
130
- if (!isAppending) {
131
- setIsFetching(true);
132
- }
133
- try {
134
- const where = buildSearchAccountsWhere(searchQuery);
135
- const queryKey = isNaN(searchQuery) ? 'name' : 'accountNumber';
136
- const { data } = yield apolloClient.query({
137
- query: SEARCH_ACCOUNTS,
138
- variables: Object.assign(Object.assign({ where, first: pageSize }, (afterCursor ? { after: afterCursor } : {})), { orderBy: { Name: { order: 'ASC' } } }),
139
- context: { fetchOptions: { signal: abortControllerRef.current.signal } },
140
- });
141
- const result = handleGraphQLSearchAccountsResponse(data);
142
- const newItems = result.items.map((item) => ({
143
- accountNumber: item.accountNumber,
144
- name: item.name,
145
- }));
146
- const sortedItems = sortAccountsByQuery(newItems, searchQuery, queryKey);
147
- if (isAppending) {
148
- setItems((prev) => [...prev, ...sortedItems]);
149
- }
150
- else {
151
- setItems(sortedItems);
152
- }
153
- setHasNextPage(result.hasNextPage);
154
- setEndCursor(result.endCursor);
155
- setCurrentSearchQuery(searchQuery);
156
- }
157
- catch (err) {
158
- if ((err === null || err === void 0 ? void 0 : err.name) !== 'AbortError') {
159
- console.error('Failed to search accounts via GraphQL', err);
160
- setItems([]);
161
- setHasNextPage(false);
162
- setEndCursor('');
163
- }
164
- }
165
- finally {
166
- setIsFetching(false);
167
- }
168
- }), [apolloClient]);
169
- const fetchAccountsRef = useRef(fetchAccounts);
170
- fetchAccountsRef.current = fetchAccounts;
171
- const debouncedFetchAccounts = useMemo(() => { var _a; return debounce((value) => fetchAccountsRef.current(value), (_a = props.delay) !== null && _a !== void 0 ? _a : 300); }, [props.delay]);
172
- useEffect(() => {
173
- return () => {
174
- debouncedFetchAccounts.cancel();
175
- };
176
- }, [debouncedFetchAccounts]);
122
+ const { query: searchQuery, queryKey } = parseAccountSearchQuery(rawQuery);
123
+ const fields = ['accountNumber', 'accountId', 'name', 'subscriptionAbuse'].join(',');
124
+ const params = Object.assign({ fields, limit: 60, accountNumberNotNull: true }, (queryKey === 'accountNumber' ? { accountNumberLike: searchQuery } : { nameLike: searchQuery }));
125
+ const response = request && (yield request(params));
126
+ const options = response && response.items && response.items.length ? response.items : [];
127
+ const sortedOptions = sortAccountsByQuery(options, searchQuery, queryKey);
128
+ setItems(sortedOptions);
129
+ });
177
130
  const onOuterClick = () => {
178
131
  setQueryLabel(props.selectedAccounts || []);
179
132
  setSelectedItems(props.selectedAccounts || []);
@@ -209,19 +162,15 @@ function AccountSelectorInternal(props) {
209
162
  (_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
210
163
  };
211
164
  const onFilter = (_event, value) => {
165
+ const trimmed = value.trim();
212
166
  setQuery(value);
213
- setIsQueryChanged(!isEmpty(value));
214
- setFocusedItemIndex(null);
215
- if (isEmpty(value)) {
216
- debouncedFetchAccounts.cancel();
217
- setItems([]);
218
- setIsFetching(false);
219
- setHasNextPage(false);
220
- setEndCursor('');
221
- return;
167
+ setIsQueryChanged(!isEmpty(trimmed));
168
+ if (!isEmpty(trimmed)) {
169
+ setIsOpen(true);
222
170
  }
223
- setIsFetching(true);
224
- debouncedFetchAccounts(value);
171
+ fetchAccounts(value);
172
+ setResultSize(pageSize);
173
+ setFocusedItemIndex(null);
225
174
  };
226
175
  const onToggleClick = () => {
227
176
  setIsOpen((pre) => !pre);
@@ -237,9 +186,6 @@ function AccountSelectorInternal(props) {
237
186
  setSelectedItems([]);
238
187
  setItems([]);
239
188
  setIsQueryChanged(false);
240
- setHasNextPage(false);
241
- setEndCursor('');
242
- setCurrentSearchQuery('');
243
189
  (_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
244
190
  };
245
191
  const onSelect = (selection) => {
@@ -1,10 +1,4 @@
1
1
  import './embeddedServiceChat.css';
2
2
  import { FC } from 'react';
3
- /**
4
- * Bootstraps Salesforce Enhanced Messaging.
5
- * The messaging widget (button + chat window) is rendered by the Salesforce
6
- * bootstrap script; this component only triggers initialisation and shows a
7
- * spinner while the script loads.
8
- */
9
3
  export declare const EmbeddedServiceChat: FC;
10
4
  //# sourceMappingURL=EmbeddedServiceChat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIlC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,EAajC,CAAC"}
1
+ {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAAoB,MAAM,OAAO,CAAC;AAMpD,eAAO,MAAM,mBAAmB,EAAE,EA6HjC,CAAC"}
@@ -1,20 +1,55 @@
1
1
  import './embeddedServiceChat.css';
2
- import { Spinner } from '@patternfly/react-core';
3
- import React from 'react';
4
- import { useChatInit } from '../../hooks/useChatInit';
5
- /**
6
- * Bootstraps Salesforce Enhanced Messaging.
7
- * The messaging widget (button + chat window) is rendered by the Salesforce
8
- * bootstrap script; this component only triggers initialisation and shows a
9
- * spinner while the script loads.
10
- */
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, { useRef, useState } from 'react';
5
+ import { Trans, useTranslation } from 'react-i18next';
6
+ import { FeatureAnnouncementKeys, NewFeaturePopoverAnnouncement, useChatInit } from '../..';
7
+ import { ChatSVGIcon } from './ChatSVGIcon';
11
8
  export const EmbeddedServiceChat = () => {
12
- const { loadingChat, chatServiceNotAvailable, hasBlockedByCookie } = useChatInit();
13
- if (chatServiceNotAvailable || hasBlockedByCookie)
9
+ var _a;
10
+ const componentRef = useRef(null);
11
+ const { loadingChat, isChatStarted, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser, chatServiceNotAvailable, hasBlockedByCookie, getChatFormDetails, } = useChatInit();
12
+ const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
13
+ const [chatClicked, setChatClicked] = useState(false);
14
+ const { t } = useTranslation();
15
+ const sessionId = (_a = getChatFormDetails().find((item) => item.label === 'SessionId')) === null || _a === void 0 ? void 0 : _a.value;
16
+ const shouldClose = () => {
17
+ setIsBlockedErrorBoxVisible(false);
18
+ };
19
+ const shouldOpen = () => {
20
+ setIsBlockedErrorBoxVisible(true);
21
+ };
22
+ const chatErrorMessagePopover = (param) => (React.createElement("div", { className: "chatButton chatError", id: "chat-blocked-popover-selector" },
23
+ React.createElement(Popover, { "aria-label": t('Cannot connect to chat support'), alertSeverityVariant: 'danger', position: PopoverPosition.top, hasAutoWidth: true, maxWidth: '420px', headerIcon: React.createElement(ExclamationCircleIcon, { className: "pf-v6-u-danger-color-100" }), headerComponent: "h1", headerContent: React.createElement(Trans, null, "Cannot connect to chat support"), bodyContent: param === 'cookie' ? (React.createElement("p", { className: "pf-v6-u-px-md" },
24
+ React.createElement(Trans, null,
25
+ "Accept functional cookies in your",
26
+ ' ',
27
+ React.createElement(Button, { variant: ButtonVariant.link, isInline: true, onClick: (e) => {
28
+ e.preventDefault();
29
+ document.querySelector('#teconsent a[role="link"]').click();
30
+ } }, "cookie preferences"),
31
+ ' ',
32
+ "to enable the Red Hat Chat Support, then refresh page."))) : (React.createElement("p", { className: "pf-v6-u-px-md" },
33
+ React.createElement(Trans, null, "There are multiple problems that can cause this error."),
34
+ React.createElement("br", null),
35
+ React.createElement("a", { href: `https://access.redhat.com/articles/313583#${hasBlockedByBrowser
36
+ ? 'troubleshoot_browser'
37
+ : hasChatDomainsBlocked
38
+ ? 'troubleshoot_network'
39
+ : ''}`, target: "_blank", rel: "noreferrer noopener" },
40
+ React.createElement(Trans, null, "See a list of possible causes.")))), isVisible: isBlockedErrorBoxVisible, shouldClose: shouldClose, shouldOpen: shouldOpen },
41
+ React.createElement(Button, { variant: ButtonVariant.link, className: "pf-v6-u-m-0 pf-v6-u-p-0" },
42
+ React.createElement(ChatSVGIcon, null)))));
43
+ if (chatServiceNotAvailable)
14
44
  return React.createElement(React.Fragment, null);
15
- if (loadingChat) {
16
- return (React.createElement("div", { className: "chatButton" },
17
- React.createElement(Spinner, { diameter: "28px", className: "pf-v6-u-m-xs" })));
18
- }
19
- return React.createElement(React.Fragment, null);
45
+ return loadingChat ? (React.createElement("div", { className: "chatButton" },
46
+ 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: () => {
47
+ setChatClicked(true);
48
+ if (sessionId) {
49
+ onStartChat();
50
+ }
51
+ }, "data-tracking-id": "embedded-service-chat", ref: componentRef, id: "chat-bot-wrapper" },
52
+ React.createElement(ChatSVGIcon, null),
53
+ 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,
54
+ React.createElement(Trans, null, "Support now has a chatbot (beta). Try it if you need help with a case.")), triggerRef: () => document.getElementById('chat-bot-wrapper') }))) : (React.createElement(React.Fragment, null));
20
55
  };
@@ -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
+ ];
@@ -18,3 +18,54 @@
18
18
  body:has(.pf-chatbot) .chatButton {
19
19
  display: none !important;
20
20
  }
21
+
22
+ .chatError {
23
+ opacity: 0.7;
24
+ }
25
+
26
+ /* Requested by CCM team */
27
+ .agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
28
+ text-align: left;
29
+ }
30
+
31
+ /* Adding fowling CSS as requested by CCM team (Sudhir Panda) */
32
+ .embeddedServiceLiveAgentStateChat .chatSessionStartTime {
33
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
34
+ }
35
+ .embeddedServiceLiveAgentStateChatItem.chatMessage {
36
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
37
+ }
38
+ .embeddedServiceLiveAgentStateChatItem.chatMessage button {
39
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
40
+ }
41
+ .embeddedServiceHelpButton .helpButton .uiButton {
42
+ background-color: #005290;
43
+ font-family: 'Arial', sans-serif;
44
+ }
45
+ .embeddedServiceHelpButton .helpButton .uiButton:focus {
46
+ outline: 1px solid #005290;
47
+ }
48
+ .agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
49
+ text-align: left;
50
+ font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
51
+ }
52
+ /* red hat chat icon */
53
+ .embeddedServiceLiveAgentStateChatAvatar.isLightningOutContext .agentIconColor0 {
54
+ background-image: url('https://access.redhat.com/chrome_themes/nimbus/img/red-hat-customer-portal.svg');
55
+ background-repeat: no-repeat;
56
+ background-size: 420% !important;
57
+ font-size: 0 !important;
58
+ background-color: #fff !important;
59
+ }
60
+
61
+ /* user chat bubble */
62
+ .chasitor.chat-content[CLWCP-lwcchatpack_lwcchatpack] {
63
+ background: #fff !important;
64
+ color: #0066cc !important;
65
+ border: #0066cc 1px solid !important;
66
+ }
67
+
68
+ /* timeout text background color */
69
+ .embeddedServiceSidebar .headerAnnouncement p {
70
+ background-color: #151515;
71
+ }
@@ -6,5 +6,6 @@ export * from './useCanEditCase';
6
6
  export * from './useCanCreateCase';
7
7
  export * from './useUserPreferences';
8
8
  export * from './useChatInit';
9
+ export * from './usePreChatFormDetails';
9
10
  export * from './useChatConfig';
10
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;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,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"}
@@ -6,4 +6,5 @@ export * from './useCanEditCase';
6
6
  export * from './useCanCreateCase';
7
7
  export * from './useUserPreferences';
8
8
  export * from './useChatInit';
9
+ export * from './usePreChatFormDetails';
9
10
  export * from './useChatConfig';
@@ -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
  };