@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
@@ -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, mapGraphQLCaseDetailsToCasePayload, 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,55 +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 graphqlCaseDetails = yield fetchCaseDetailsByCaseNumber(apolloClient, caseNumber);
386
- if (!graphqlCaseDetails) {
387
- throw new Error(`Case ${caseNumber} was not found`);
388
- }
389
- const caseDetails = mapGraphQLCaseDetailsToCasePayload(graphqlCaseDetails);
390
- caseDispatch({
391
- type: CaseDetailsFetchActions.receivedCaseDetails,
392
- payload: {
393
- caseDetails,
394
- isClosed: ((_a = graphqlCaseDetails.status) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'closed',
395
- caseNoOfCreatedCase: caseNumber,
396
- },
397
- });
398
- if (setCaseAccountNumber) {
399
- yield setCaseAccountNumber(caseDispatch, graphqlCaseDetails.accountNumberRef, false, {}, apolloClient);
400
- }
401
- }
402
- catch (error) {
403
- caseDispatch({
404
- type: CaseDetailsFetchActions.receivedCaseDetailsError,
405
- payload: { caseDetailsError: error },
406
- });
407
- }
408
- });
409
- export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
410
- var _a;
320
+ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
411
321
  dispatch({
412
322
  type: GlobalMetadataReducerConstants.setCaseStatuses,
413
323
  payload: { allCaseStatuses: getApiResourceObject([], true) },
414
324
  });
415
325
  try {
416
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
417
- const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
326
+ const caseStatusesResponse = yield caseMetadata.getStatuses(isSecureSupport);
418
327
  dispatch({
419
328
  type: GlobalMetadataReducerConstants.setCaseStatuses,
420
- payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
329
+ payload: { allCaseStatuses: getApiResourceObject(caseStatusesResponse.items) },
421
330
  });
422
331
  }
423
332
  catch (e) {
@@ -427,26 +336,25 @@ export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, vo
427
336
  });
428
337
  }
429
338
  });
430
- export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
431
- 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 = {}) {
432
340
  try {
433
341
  dispatch({
434
342
  type: GlobalMetadataReducerConstants.setAllProducts,
435
343
  payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
436
344
  });
437
- const { data } = yield apolloClient.query({
438
- query: GET_PRODUCTS,
439
- variables: {
440
- where: {
441
- ParentProduct__c: { eq: null },
442
- IsActive: { eq: true },
443
- },
444
- first: 200,
445
- orderBy: { Name: { order: 'ASC' } },
446
- },
447
- });
448
- 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 : [];
449
- 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);
450
358
  dispatch({
451
359
  type: GlobalMetadataReducerConstants.setAllProducts,
452
360
  payload: { allProducts: getApiResourceObject(allProducts) },
@@ -459,51 +367,18 @@ export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void
459
367
  });
460
368
  }
461
369
  });
462
- export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
463
- var _a, _b, _c, _d;
464
- dispatch({
465
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
466
- payload: { caseRecordTypes: getApiResourceObject({}, true) },
467
- });
468
- try {
469
- const { data } = yield apolloClient.query({
470
- query: GET_CASE_RECORD_TYPES,
471
- });
472
- 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 : [];
473
- const caseRecordTypes = {};
474
- recordTypeInfos.forEach((info) => {
475
- caseRecordTypes[info.name] = info.recordTypeId;
476
- });
477
- setCaseRecordTypes(caseRecordTypes);
478
- dispatch({
479
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
480
- payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
481
- });
482
- }
483
- catch (e) {
484
- dispatch({
485
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
486
- payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
487
- });
488
- }
489
- });
490
370
  export const setAllProducts = (dispatch, allProducts) => {
491
371
  dispatch({
492
372
  type: GlobalMetadataReducerConstants.setAllProducts,
493
373
  payload: { allProducts: getApiResourceObject(allProducts) },
494
374
  });
495
375
  };
496
- 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) {
497
- 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;
498
378
  let accountNumber = token.account_number;
499
379
  if (silent) {
500
380
  try {
501
- const { data } = yield apolloClient.query({
502
- query: GET_ACCOUNT,
503
- variables: getAccountQueryVariables(accountNumber),
504
- });
505
- 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 : [];
506
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
381
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
507
382
  dispatch({
508
383
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
509
384
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -519,13 +394,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
519
394
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
520
395
  payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
521
396
  });
522
- const { data } = yield apolloClient.query({
523
- query: GET_ACCOUNT,
524
- variables: getAccountQueryVariables(accountNumber),
525
- fetchPolicy: 'network-only',
526
- });
527
- 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 : [];
528
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
397
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
529
398
  dispatch({
530
399
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
531
400
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -533,7 +402,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
533
402
  return loggedInUsersAccount;
534
403
  }
535
404
  catch (e) {
536
- (_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, {
537
406
  tags: {
538
407
  portal_app: window.app || 'Portal Case Management',
539
408
  error_effect: 'PCM - App wide error',
@@ -555,7 +424,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
555
424
  type: GlobalMetadataReducerConstants.setLoggedInUser,
556
425
  payload: { loggedInUser: getApiResourceObject({}, true) },
557
426
  });
558
- const loggedInUser = yield contacts.getCurrentContact({
427
+ let loggedInUser = yield contacts.getCurrentContact({
559
428
  userId: token.sub,
560
429
  assumeEntitledIfSubscriptionServiceUnavailable: true,
561
430
  });
@@ -563,7 +432,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
563
432
  type: GlobalMetadataReducerConstants.setLoggedInUser,
564
433
  payload: { loggedInUser: getApiResourceObject(loggedInUser) },
565
434
  });
566
- // TODO: migrate to GraphQL - bookmark accounts skipped for now
435
+ // Saving bookmarked accounts separately.
567
436
  const canViewBookmarkAccounts = loggedInUser.isInternal;
568
437
  if (canViewBookmarkAccounts) {
569
438
  fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
@@ -586,18 +455,16 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
586
455
  });
587
456
  }
588
457
  });
589
- export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
590
- var _a;
591
- dispatch({
592
- type: GlobalMetadataReducerConstants.setCaseLanguages,
593
- payload: { caseLanguages: getApiResourceObject([], true) },
594
- });
458
+ export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
595
459
  try {
596
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
597
- const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
598
460
  dispatch({
599
461
  type: GlobalMetadataReducerConstants.setCaseLanguages,
600
- 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) },
601
468
  });
602
469
  }
603
470
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.275",
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.181",
39
+ "@rh-support/components": "2.5.182",
40
40
  "@rh-support/types": "2.0.26",
41
- "@rh-support/user-permissions": "2.5.127",
42
- "@rh-support/utils": "2.5.110",
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": "d1a226af32eb5997a31c34001b6146be141c8911"
92
+ "gitHead": "5a3a62786c13896575f6db3805b3a0dc0bd1299f"
93
93
  }