@rh-support/react-context 2.5.272 → 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 -167
  29. package/package.json +5 -5
@@ -7,8 +7,8 @@ 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 { accounts, caseMetadata, contacts, customEmail, maintenance, publicApi, userPreferences, } from '@cee-eng/hydrajs';
11
- import { buildPicklistInput, fetchCaseDetailsByCaseNumber, fetchPicklistValues, GET_ACCOUNT, GET_CASE_RECORD_TYPES, GET_PRODUCTS, getAccountQueryVariables, getApiResourceObject, handleGraphQLAccountResponse, handleGraphQLProductsResponse, setCaseRecordTypes, severitySort, } from '@rh-support/utils';
10
+ import { accounts, caseMetadata, contacts, customEmail, maintenance, products, publicApi, userPreferences, } from '@cee-eng/hydrajs';
11
+ import { getApiResourceObject, handleEntitledProductResponse, handleProductSearchResponse, severitySort, } from '@rh-support/utils';
12
12
  import differenceBy from 'lodash/differenceBy';
13
13
  import filter from 'lodash/filter';
14
14
  import find from 'lodash/find';
@@ -80,7 +80,6 @@ export var GlobalMetadataReducerConstants;
80
80
  GlobalMetadataReducerConstants["getNoclusteridreasons"] = "getNoclusteridreasons";
81
81
  GlobalMetadataReducerConstants["setIsSharingHostnameswithRHt"] = "setIsSharingHostnameswithRHt";
82
82
  GlobalMetadataReducerConstants["setCaseListTraditionalSupportAgreed"] = "setCaseListTraditionalSupportAgreed";
83
- GlobalMetadataReducerConstants["setCaseRecordTypes"] = "setCaseRecordTypes";
84
83
  })(GlobalMetadataReducerConstants || (GlobalMetadataReducerConstants = {}));
85
84
  const initialProductResponse = {
86
85
  topProducts: [],
@@ -119,7 +118,6 @@ export const initialGlobalMetadataState = {
119
118
  },
120
119
  referrerUrl: null,
121
120
  caseNoClusterIdReasons: getApiResourceObject([]),
122
- caseRecordTypes: getApiResourceObject({}),
123
121
  caseListTraditionalSupportAgreed: false,
124
122
  };
125
123
  // Resucers
@@ -220,9 +218,6 @@ export const globalMetadataReducer = (pState, action) => {
220
218
  case GlobalMetadataReducerConstants.setCaseListTraditionalSupportAgreed: {
221
219
  return Object.assign(Object.assign({}, pState), { caseListTraditionalSupportAgreed: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.caseListTraditionalSupportAgreed });
222
220
  }
223
- case GlobalMetadataReducerConstants.setCaseRecordTypes: {
224
- return Object.assign(Object.assign({}, pState), { caseRecordTypes: action.payload.caseRecordTypes });
225
- }
226
221
  default: {
227
222
  return pState;
228
223
  }
@@ -283,33 +278,7 @@ export const addEditbookmarks = (dispatch, allBookmarks, updatedAccounts, select
283
278
  payload: { bookmarkedGroupAccounts: getApiResourceObject(allBookmarksCopy, false) },
284
279
  });
285
280
  };
286
- export const fetchCaseTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
287
- var _a;
288
- dispatch({
289
- type: GlobalMetadataReducerConstants.setCaseTypes,
290
- payload: { allCaseTypes: getApiResourceObject([], true) },
291
- });
292
- try {
293
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Type']));
294
- const allCaseTypes = getProcessedCaseTypes((_a = picklists.Type) !== null && _a !== void 0 ? _a : []);
295
- dispatch({
296
- type: GlobalMetadataReducerConstants.setCaseTypes,
297
- payload: { allCaseTypes: getApiResourceObject(allCaseTypes) },
298
- });
299
- }
300
- catch (e) {
301
- dispatch({
302
- type: GlobalMetadataReducerConstants.setCaseTypes,
303
- payload: { allCaseTypes: getApiResourceObject([], false, true, e.message) },
304
- });
305
- }
306
- // const caseTypes = await caseMetadata.getTypes(isSecureSupport);
307
- // dispatch({
308
- // type: GlobalMetadataReducerConstants.setCaseTypes,
309
- // payload: { allCaseTypes: getApiResourceObject(getProcessedCaseTypes(caseTypes.items)) },
310
- // });
311
- });
312
- export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
281
+ export const fetchCaseTypes = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
313
282
  dispatch({
314
283
  type: GlobalMetadataReducerConstants.setCaseTypes,
315
284
  payload: { allCaseTypes: getApiResourceObject([], true) },
@@ -328,28 +297,7 @@ export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void
328
297
  });
329
298
  }
330
299
  });
331
- export const fetchCaseSeverities = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
332
- var _a;
333
- dispatch({
334
- type: GlobalMetadataReducerConstants.setCaseSeverities,
335
- payload: { allCaseSeverities: getApiResourceObject([], true) },
336
- });
337
- try {
338
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Priority']));
339
- const allCaseSeverities = [...((_a = picklists.Priority) !== null && _a !== void 0 ? _a : [])].sort((sevA, sevB) => severitySort(sevA, sevB));
340
- dispatch({
341
- type: GlobalMetadataReducerConstants.setCaseSeverities,
342
- payload: { allCaseSeverities: getApiResourceObject(allCaseSeverities) },
343
- });
344
- }
345
- catch (e) {
346
- dispatch({
347
- type: GlobalMetadataReducerConstants.setCaseSeverities,
348
- payload: { allCaseSeverities: getApiResourceObject([], false, true, e.message) },
349
- });
350
- }
351
- });
352
- export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
300
+ export const fetchCaseSeverities = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
353
301
  dispatch({
354
302
  type: GlobalMetadataReducerConstants.setCaseSeverities,
355
303
  payload: { allCaseSeverities: getApiResourceObject([], true) },
@@ -369,54 +317,16 @@ export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter
369
317
  });
370
318
  }
371
319
  });
372
- /** Case reducer action types kept in sync with CaseReducerConstants in troubleshoot */
373
- const CaseDetailsFetchActions = {
374
- requestCaseDetails: 'requestCaseDetails',
375
- receivedCaseDetails: 'receivedCaseDetails',
376
- receivedCaseDetailsError: 'receivedCaseDetailsError',
377
- };
378
- export const fetchCaseDetails = (caseDispatch, apolloClient, caseNumber, setCaseAccountNumber) => __awaiter(void 0, void 0, void 0, function* () {
379
- var _a;
380
- caseDispatch({
381
- type: CaseDetailsFetchActions.requestCaseDetails,
382
- payload: { caseDetails: { caseNumber } },
383
- });
384
- try {
385
- const caseDetails = yield fetchCaseDetailsByCaseNumber(apolloClient, caseNumber);
386
- if (!caseDetails) {
387
- throw new Error(`Case ${caseNumber} was not found`);
388
- }
389
- caseDispatch({
390
- type: CaseDetailsFetchActions.receivedCaseDetails,
391
- payload: {
392
- caseDetails,
393
- isClosed: ((_a = caseDetails.status) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'closed',
394
- caseNoOfCreatedCase: caseNumber,
395
- },
396
- });
397
- if (setCaseAccountNumber) {
398
- yield setCaseAccountNumber(caseDispatch, caseDetails.accountNumberRef, false, {}, apolloClient);
399
- }
400
- }
401
- catch (error) {
402
- caseDispatch({
403
- type: CaseDetailsFetchActions.receivedCaseDetailsError,
404
- payload: { caseDetailsError: error },
405
- });
406
- }
407
- });
408
- export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
409
- var _a;
320
+ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
410
321
  dispatch({
411
322
  type: GlobalMetadataReducerConstants.setCaseStatuses,
412
323
  payload: { allCaseStatuses: getApiResourceObject([], true) },
413
324
  });
414
325
  try {
415
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
416
- const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
326
+ const caseStatusesResponse = yield caseMetadata.getStatuses(isSecureSupport);
417
327
  dispatch({
418
328
  type: GlobalMetadataReducerConstants.setCaseStatuses,
419
- payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
329
+ payload: { allCaseStatuses: getApiResourceObject(caseStatusesResponse.items) },
420
330
  });
421
331
  }
422
332
  catch (e) {
@@ -426,26 +336,25 @@ export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, vo
426
336
  });
427
337
  }
428
338
  });
429
- export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
430
- var _a, _b, _c, _d;
339
+ export const fetchProducts = (dispatch_1, ownerSSOUsername_1, ...args_1) => __awaiter(void 0, [dispatch_1, ownerSSOUsername_1, ...args_1], void 0, function* (dispatch, ownerSSOUsername, params = {}) {
431
340
  try {
432
341
  dispatch({
433
342
  type: GlobalMetadataReducerConstants.setAllProducts,
434
343
  payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
435
344
  });
436
- const { data } = yield apolloClient.query({
437
- query: GET_PRODUCTS,
438
- variables: {
439
- where: {
440
- ParentProduct__c: { eq: null },
441
- IsActive: { eq: true },
442
- },
443
- first: 200,
444
- orderBy: { Name: { order: 'ASC' } },
445
- },
446
- });
447
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.SalesforceSupportProduct2) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
448
- const allProducts = handleGraphQLProductsResponse(edges);
345
+ /**
346
+ * Here we are trying to fetch products from two sources (getSEProductsList and getProducts) and if even first source (getSEProductsList) fail to deliver product information
347
+ * we still need to use second source (getProducts) to parse and list product
348
+ */
349
+ const response = yield Promise.allSettled([
350
+ products.getSEProductsList(params),
351
+ products.getProducts(ownerSSOUsername),
352
+ ]);
353
+ const productsResultAll = response[0].status === 'fulfilled' ? response[0].value : [];
354
+ const productsResultEntitled = response[1].status === 'fulfilled' ? response[1].value : [];
355
+ const allProducts = productsResultAll.length
356
+ ? handleProductSearchResponse(productsResultAll, productsResultEntitled)
357
+ : handleEntitledProductResponse(productsResultEntitled);
449
358
  dispatch({
450
359
  type: GlobalMetadataReducerConstants.setAllProducts,
451
360
  payload: { allProducts: getApiResourceObject(allProducts) },
@@ -458,51 +367,18 @@ export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void
458
367
  });
459
368
  }
460
369
  });
461
- export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
462
- var _a, _b, _c, _d;
463
- dispatch({
464
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
465
- payload: { caseRecordTypes: getApiResourceObject({}, true) },
466
- });
467
- try {
468
- const { data } = yield apolloClient.query({
469
- query: GET_CASE_RECORD_TYPES,
470
- });
471
- const recordTypeInfos = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _a === void 0 ? void 0 : _a.objectInfos) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.recordTypeInfos) !== null && _d !== void 0 ? _d : [];
472
- const caseRecordTypes = {};
473
- recordTypeInfos.forEach((info) => {
474
- caseRecordTypes[info.name] = info.recordTypeId;
475
- });
476
- setCaseRecordTypes(caseRecordTypes);
477
- dispatch({
478
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
479
- payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
480
- });
481
- }
482
- catch (e) {
483
- dispatch({
484
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
485
- payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
486
- });
487
- }
488
- });
489
370
  export const setAllProducts = (dispatch, allProducts) => {
490
371
  dispatch({
491
372
  type: GlobalMetadataReducerConstants.setAllProducts,
492
373
  payload: { allProducts: getApiResourceObject(allProducts) },
493
374
  });
494
375
  };
495
- export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __awaiter(void 0, [dispatch_1, token_1, ...args_1], void 0, function* (dispatch, token, silent = false, apolloClient) {
496
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
376
+ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __awaiter(void 0, [dispatch_1, token_1, ...args_1], void 0, function* (dispatch, token, silent = false) {
377
+ var _a;
497
378
  let accountNumber = token.account_number;
498
379
  if (silent) {
499
380
  try {
500
- const { data } = yield apolloClient.query({
501
- query: GET_ACCOUNT,
502
- variables: getAccountQueryVariables(accountNumber),
503
- });
504
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.SalesforceSupportAccount) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
505
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
381
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
506
382
  dispatch({
507
383
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
508
384
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -518,13 +394,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
518
394
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
519
395
  payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
520
396
  });
521
- const { data } = yield apolloClient.query({
522
- query: GET_ACCOUNT,
523
- variables: getAccountQueryVariables(accountNumber),
524
- fetchPolicy: 'network-only',
525
- });
526
- const edges = (_h = (_g = (_f = (_e = data === null || data === void 0 ? void 0 : data.salesforce_support_uiapi) === null || _e === void 0 ? void 0 : _e.query) === null || _f === void 0 ? void 0 : _f.SalesforceSupportAccount) === null || _g === void 0 ? void 0 : _g.edges) !== null && _h !== void 0 ? _h : [];
527
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
397
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
528
398
  dispatch({
529
399
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
530
400
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -532,7 +402,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
532
402
  return loggedInUsersAccount;
533
403
  }
534
404
  catch (e) {
535
- (_j = window.sessionjs) === null || _j === void 0 ? void 0 : _j.reportProblem(e, {
405
+ (_a = window.sessionjs) === null || _a === void 0 ? void 0 : _a.reportProblem(e, {
536
406
  tags: {
537
407
  portal_app: window.app || 'Portal Case Management',
538
408
  error_effect: 'PCM - App wide error',
@@ -554,7 +424,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
554
424
  type: GlobalMetadataReducerConstants.setLoggedInUser,
555
425
  payload: { loggedInUser: getApiResourceObject({}, true) },
556
426
  });
557
- const loggedInUser = yield contacts.getCurrentContact({
427
+ let loggedInUser = yield contacts.getCurrentContact({
558
428
  userId: token.sub,
559
429
  assumeEntitledIfSubscriptionServiceUnavailable: true,
560
430
  });
@@ -562,7 +432,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
562
432
  type: GlobalMetadataReducerConstants.setLoggedInUser,
563
433
  payload: { loggedInUser: getApiResourceObject(loggedInUser) },
564
434
  });
565
- // TODO: migrate to GraphQL - bookmark accounts skipped for now
435
+ // Saving bookmarked accounts separately.
566
436
  const canViewBookmarkAccounts = loggedInUser.isInternal;
567
437
  if (canViewBookmarkAccounts) {
568
438
  fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
@@ -585,18 +455,16 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
585
455
  });
586
456
  }
587
457
  });
588
- export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
589
- var _a;
590
- dispatch({
591
- type: GlobalMetadataReducerConstants.setCaseLanguages,
592
- payload: { caseLanguages: getApiResourceObject([], true) },
593
- });
458
+ export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
594
459
  try {
595
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
596
- const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
597
460
  dispatch({
598
461
  type: GlobalMetadataReducerConstants.setCaseLanguages,
599
- payload: { caseLanguages: getApiResourceObject(caseLanguages) },
462
+ payload: { caseLanguages: getApiResourceObject([], true) },
463
+ });
464
+ const response = yield caseMetadata.getLanguagesMetadata();
465
+ dispatch({
466
+ type: GlobalMetadataReducerConstants.setCaseLanguages,
467
+ payload: { caseLanguages: getApiResourceObject(response.items) },
600
468
  });
601
469
  }
602
470
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.272",
3
+ "version": "2.5.276",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -36,10 +36,10 @@
36
36
  "@cee-eng/hydrajs": "4.18.111",
37
37
  "@patternfly/react-core": "6.2.1",
38
38
  "@patternfly/react-icons": "6.2.1",
39
- "@rh-support/components": "2.5.178",
39
+ "@rh-support/components": "2.5.182",
40
40
  "@rh-support/types": "2.0.26",
41
- "@rh-support/user-permissions": "2.5.124",
42
- "@rh-support/utils": "2.5.107",
41
+ "@rh-support/user-permissions": "2.5.128",
42
+ "@rh-support/utils": "2.5.92",
43
43
  "i18next": "^23.15.0",
44
44
  "localforage": "^1.10.0",
45
45
  "lodash": "^4.17.21",
@@ -89,5 +89,5 @@
89
89
  "defaults and supports es6-module",
90
90
  "maintained node versions"
91
91
  ],
92
- "gitHead": "841d3531777ef141d920f72fa492c1e53d100e9f"
92
+ "gitHead": "5a3a62786c13896575f6db3805b3a0dc0bd1299f"
93
93
  }