@rh-support/react-context 2.5.276 → 2.5.277

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 +1 -3
  2. package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
  3. package/lib/esm/GlobalContextWrapper.js +9 -3
  4. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts +1 -2
  5. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts.map +1 -1
  6. package/lib/esm/components/AccountSelector/AccountSelectorInternal.js +93 -37
  7. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +6 -0
  8. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
  9. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +16 -51
  10. package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +0 -51
  11. package/lib/esm/hooks/index.d.ts +0 -1
  12. package/lib/esm/hooks/index.d.ts.map +1 -1
  13. package/lib/esm/hooks/index.js +0 -1
  14. package/lib/esm/hooks/useChatConfig.d.ts +9 -17
  15. package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
  16. package/lib/esm/hooks/useChatConfig.js +11 -43
  17. package/lib/esm/hooks/useChatInit.d.ts +9 -13
  18. package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
  19. package/lib/esm/hooks/useChatInit.js +59 -119
  20. package/lib/esm/reducers/GlobalMetadataReducer.d.ts +49 -11
  21. package/lib/esm/reducers/GlobalMetadataReducer.d.ts.map +1 -1
  22. package/lib/esm/reducers/GlobalMetadataReducer.js +223 -38
  23. package/package.json +8 -7
  24. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +0 -12
  25. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +0 -1
  26. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +0 -29
  27. package/lib/esm/hooks/usePreChatFormDetails.d.ts +0 -12
  28. package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +0 -1
  29. package/lib/esm/hooks/usePreChatFormDetails.js +0 -61
@@ -7,14 +7,16 @@ 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, products, publicApi, userPreferences, } from '@cee-eng/hydrajs';
11
- import { getApiResourceObject, handleEntitledProductResponse, handleProductSearchResponse, severitySort, } from '@rh-support/utils';
10
+ import { accounts, caseMetadata, contacts, customEmail, maintenance, publicApi, userPreferences, } from '@cee-eng/hydrajs';
11
+ import { getPhoneObj } from '@rh-support/components';
12
+ import { buildPicklistInput, fetchCaseDetailsByCaseNumber, fetchPicklistValues, GET_ACCOUNT, GET_CASE_GROUP, GET_CASE_RECORD_TYPES, GET_PRODUCTS, getAccountQueryVariables, getApiResourceObject, handleGraphQLAccountResponse, handleGraphQLProductsResponse, mapGraphQLCaseContactToOwnerState, mapGraphQLCaseDetailsToCasePayload, mapGraphQLContactPhoneToCasePhoneFields, setCaseRecordTypes, severitySort, } from '@rh-support/utils';
12
13
  import differenceBy from 'lodash/differenceBy';
13
14
  import filter from 'lodash/filter';
14
15
  import find from 'lodash/find';
15
16
  import isEmpty from 'lodash/isEmpty';
16
17
  import reduce from 'lodash/reduce';
17
18
  import sortBy from 'lodash/sortBy';
19
+ import unescape from 'lodash/unescape';
18
20
  import unionBy from 'lodash/unionBy';
19
21
  import { getProcessedCaseTypes } from './GlobalMetadataHelpers';
20
22
  export var UserPreferencesKeys;
@@ -80,6 +82,7 @@ export var GlobalMetadataReducerConstants;
80
82
  GlobalMetadataReducerConstants["getNoclusteridreasons"] = "getNoclusteridreasons";
81
83
  GlobalMetadataReducerConstants["setIsSharingHostnameswithRHt"] = "setIsSharingHostnameswithRHt";
82
84
  GlobalMetadataReducerConstants["setCaseListTraditionalSupportAgreed"] = "setCaseListTraditionalSupportAgreed";
85
+ GlobalMetadataReducerConstants["setCaseRecordTypes"] = "setCaseRecordTypes";
83
86
  })(GlobalMetadataReducerConstants || (GlobalMetadataReducerConstants = {}));
84
87
  const initialProductResponse = {
85
88
  topProducts: [],
@@ -118,6 +121,7 @@ export const initialGlobalMetadataState = {
118
121
  },
119
122
  referrerUrl: null,
120
123
  caseNoClusterIdReasons: getApiResourceObject([]),
124
+ caseRecordTypes: getApiResourceObject({}),
121
125
  caseListTraditionalSupportAgreed: false,
122
126
  };
123
127
  // Resucers
@@ -218,6 +222,9 @@ export const globalMetadataReducer = (pState, action) => {
218
222
  case GlobalMetadataReducerConstants.setCaseListTraditionalSupportAgreed: {
219
223
  return Object.assign(Object.assign({}, pState), { caseListTraditionalSupportAgreed: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.caseListTraditionalSupportAgreed });
220
224
  }
225
+ case GlobalMetadataReducerConstants.setCaseRecordTypes: {
226
+ return Object.assign(Object.assign({}, pState), { caseRecordTypes: action.payload.caseRecordTypes });
227
+ }
221
228
  default: {
222
229
  return pState;
223
230
  }
@@ -278,7 +285,33 @@ export const addEditbookmarks = (dispatch, allBookmarks, updatedAccounts, select
278
285
  payload: { bookmarkedGroupAccounts: getApiResourceObject(allBookmarksCopy, false) },
279
286
  });
280
287
  };
281
- export const fetchCaseTypes = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
288
+ export const fetchCaseTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
289
+ var _a;
290
+ dispatch({
291
+ type: GlobalMetadataReducerConstants.setCaseTypes,
292
+ payload: { allCaseTypes: getApiResourceObject([], true) },
293
+ });
294
+ try {
295
+ const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Type']));
296
+ const allCaseTypes = getProcessedCaseTypes((_a = picklists.Type) !== null && _a !== void 0 ? _a : []);
297
+ dispatch({
298
+ type: GlobalMetadataReducerConstants.setCaseTypes,
299
+ payload: { allCaseTypes: getApiResourceObject(allCaseTypes) },
300
+ });
301
+ }
302
+ catch (e) {
303
+ dispatch({
304
+ type: GlobalMetadataReducerConstants.setCaseTypes,
305
+ payload: { allCaseTypes: getApiResourceObject([], false, true, e.message) },
306
+ });
307
+ }
308
+ // const caseTypes = await caseMetadata.getTypes(isSecureSupport);
309
+ // dispatch({
310
+ // type: GlobalMetadataReducerConstants.setCaseTypes,
311
+ // payload: { allCaseTypes: getApiResourceObject(getProcessedCaseTypes(caseTypes.items)) },
312
+ // });
313
+ });
314
+ export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
282
315
  dispatch({
283
316
  type: GlobalMetadataReducerConstants.setCaseTypes,
284
317
  payload: { allCaseTypes: getApiResourceObject([], true) },
@@ -297,7 +330,28 @@ export const fetchCaseTypes = (dispatch, isSecureSupport) => __awaiter(void 0, v
297
330
  });
298
331
  }
299
332
  });
300
- export const fetchCaseSeverities = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
333
+ export const fetchCaseSeverities = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
334
+ var _a;
335
+ dispatch({
336
+ type: GlobalMetadataReducerConstants.setCaseSeverities,
337
+ payload: { allCaseSeverities: getApiResourceObject([], true) },
338
+ });
339
+ try {
340
+ const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Priority']));
341
+ const allCaseSeverities = [...((_a = picklists.Priority) !== null && _a !== void 0 ? _a : [])].sort((sevA, sevB) => severitySort(sevA, sevB));
342
+ dispatch({
343
+ type: GlobalMetadataReducerConstants.setCaseSeverities,
344
+ payload: { allCaseSeverities: getApiResourceObject(allCaseSeverities) },
345
+ });
346
+ }
347
+ catch (e) {
348
+ dispatch({
349
+ type: GlobalMetadataReducerConstants.setCaseSeverities,
350
+ payload: { allCaseSeverities: getApiResourceObject([], false, true, e.message) },
351
+ });
352
+ }
353
+ });
354
+ export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
301
355
  dispatch({
302
356
  type: GlobalMetadataReducerConstants.setCaseSeverities,
303
357
  payload: { allCaseSeverities: getApiResourceObject([], true) },
@@ -317,16 +371,57 @@ export const fetchCaseSeverities = (dispatch, isSecureSupport) => __awaiter(void
317
371
  });
318
372
  }
319
373
  });
320
- export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
374
+ /** Case reducer action types kept in sync with CaseReducerConstants in troubleshoot */
375
+ const CaseDetailsFetchActions = {
376
+ requestCaseDetails: 'requestCaseDetails',
377
+ receivedCaseDetails: 'receivedCaseDetails',
378
+ receivedCaseDetailsError: 'receivedCaseDetailsError',
379
+ };
380
+ export const fetchCaseDetails = (caseDispatch, apolloClient, caseNumber, setCaseAccountNumber) => __awaiter(void 0, void 0, void 0, function* () {
381
+ var _a, _b;
382
+ caseDispatch({
383
+ type: CaseDetailsFetchActions.requestCaseDetails,
384
+ payload: { caseDetails: { caseNumber } },
385
+ });
386
+ try {
387
+ const graphqlCaseDetails = yield fetchCaseDetailsByCaseNumber(apolloClient, caseNumber);
388
+ if (!graphqlCaseDetails) {
389
+ throw new Error(`Case ${caseNumber} was not found`);
390
+ }
391
+ const caseDetails = Object.assign(Object.assign({}, mapGraphQLCaseDetailsToCasePayload(graphqlCaseDetails)), mapGraphQLContactPhoneToCasePhoneFields(graphqlCaseDetails.contactPhone, (phone) => {
392
+ const { countryCode, phoneLine } = getPhoneObj(phone);
393
+ return { countryCode, phoneLine: phoneLine || '' };
394
+ }));
395
+ const ownerFromGraphQL = mapGraphQLCaseContactToOwnerState(graphqlCaseDetails);
396
+ caseDispatch({
397
+ type: CaseDetailsFetchActions.receivedCaseDetails,
398
+ payload: Object.assign(Object.assign({ caseDetails }, (ownerFromGraphQL ? { selectedOwner: getApiResourceObject(ownerFromGraphQL) } : {})), { isClosed: (_a = graphqlCaseDetails.isClosed) !== null && _a !== void 0 ? _a : ((_b = graphqlCaseDetails.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'closed', caseNoOfCreatedCase: caseNumber }),
399
+ });
400
+ if (setCaseAccountNumber) {
401
+ yield setCaseAccountNumber(caseDispatch, graphqlCaseDetails.accountNumberRef, false, {}, apolloClient);
402
+ }
403
+ return caseDetails;
404
+ }
405
+ catch (error) {
406
+ caseDispatch({
407
+ type: CaseDetailsFetchActions.receivedCaseDetailsError,
408
+ payload: { caseDetailsError: error },
409
+ });
410
+ return undefined;
411
+ }
412
+ });
413
+ export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
414
+ var _a;
321
415
  dispatch({
322
416
  type: GlobalMetadataReducerConstants.setCaseStatuses,
323
417
  payload: { allCaseStatuses: getApiResourceObject([], true) },
324
418
  });
325
419
  try {
326
- const caseStatusesResponse = yield caseMetadata.getStatuses(isSecureSupport);
420
+ const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
421
+ const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
327
422
  dispatch({
328
423
  type: GlobalMetadataReducerConstants.setCaseStatuses,
329
- payload: { allCaseStatuses: getApiResourceObject(caseStatusesResponse.items) },
424
+ payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
330
425
  });
331
426
  }
332
427
  catch (e) {
@@ -336,25 +431,26 @@ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0,
336
431
  });
337
432
  }
338
433
  });
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 = {}) {
434
+ export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
435
+ var _a, _b, _c, _d;
340
436
  try {
341
437
  dispatch({
342
438
  type: GlobalMetadataReducerConstants.setAllProducts,
343
439
  payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
344
440
  });
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);
441
+ const { data } = yield apolloClient.query({
442
+ query: GET_PRODUCTS,
443
+ variables: {
444
+ where: {
445
+ ParentProduct__c: { eq: null },
446
+ IsActive: { eq: true },
447
+ },
448
+ first: 200,
449
+ orderBy: { Name: { order: 'ASC' } },
450
+ },
451
+ });
452
+ 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 : [];
453
+ const allProducts = handleGraphQLProductsResponse(edges);
358
454
  dispatch({
359
455
  type: GlobalMetadataReducerConstants.setAllProducts,
360
456
  payload: { allProducts: getApiResourceObject(allProducts) },
@@ -367,18 +463,51 @@ export const fetchProducts = (dispatch_1, ownerSSOUsername_1, ...args_1) => __aw
367
463
  });
368
464
  }
369
465
  });
466
+ export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
467
+ var _a, _b, _c, _d;
468
+ dispatch({
469
+ type: GlobalMetadataReducerConstants.setCaseRecordTypes,
470
+ payload: { caseRecordTypes: getApiResourceObject({}, true) },
471
+ });
472
+ try {
473
+ const { data } = yield apolloClient.query({
474
+ query: GET_CASE_RECORD_TYPES,
475
+ });
476
+ 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 : [];
477
+ const caseRecordTypes = {};
478
+ recordTypeInfos.forEach((info) => {
479
+ caseRecordTypes[info.name] = info.recordTypeId;
480
+ });
481
+ setCaseRecordTypes(caseRecordTypes);
482
+ dispatch({
483
+ type: GlobalMetadataReducerConstants.setCaseRecordTypes,
484
+ payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
485
+ });
486
+ }
487
+ catch (e) {
488
+ dispatch({
489
+ type: GlobalMetadataReducerConstants.setCaseRecordTypes,
490
+ payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
491
+ });
492
+ }
493
+ });
370
494
  export const setAllProducts = (dispatch, allProducts) => {
371
495
  dispatch({
372
496
  type: GlobalMetadataReducerConstants.setAllProducts,
373
497
  payload: { allProducts: getApiResourceObject(allProducts) },
374
498
  });
375
499
  };
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;
500
+ 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) {
501
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
378
502
  let accountNumber = token.account_number;
379
503
  if (silent) {
380
504
  try {
381
- const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
505
+ const { data } = yield apolloClient.query({
506
+ query: GET_ACCOUNT,
507
+ variables: getAccountQueryVariables(accountNumber),
508
+ });
509
+ 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 : [];
510
+ const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
382
511
  dispatch({
383
512
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
384
513
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -394,7 +523,13 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
394
523
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
395
524
  payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
396
525
  });
397
- const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
526
+ const { data } = yield apolloClient.query({
527
+ query: GET_ACCOUNT,
528
+ variables: getAccountQueryVariables(accountNumber),
529
+ fetchPolicy: 'network-only',
530
+ });
531
+ 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 : [];
532
+ const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
398
533
  dispatch({
399
534
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
400
535
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -402,7 +537,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
402
537
  return loggedInUsersAccount;
403
538
  }
404
539
  catch (e) {
405
- (_a = window.sessionjs) === null || _a === void 0 ? void 0 : _a.reportProblem(e, {
540
+ (_j = window.sessionjs) === null || _j === void 0 ? void 0 : _j.reportProblem(e, {
406
541
  tags: {
407
542
  portal_app: window.app || 'Portal Case Management',
408
543
  error_effect: 'PCM - App wide error',
@@ -424,7 +559,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
424
559
  type: GlobalMetadataReducerConstants.setLoggedInUser,
425
560
  payload: { loggedInUser: getApiResourceObject({}, true) },
426
561
  });
427
- let loggedInUser = yield contacts.getCurrentContact({
562
+ const loggedInUser = yield contacts.getCurrentContact({
428
563
  userId: token.sub,
429
564
  assumeEntitledIfSubscriptionServiceUnavailable: true,
430
565
  });
@@ -432,7 +567,7 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
432
567
  type: GlobalMetadataReducerConstants.setLoggedInUser,
433
568
  payload: { loggedInUser: getApiResourceObject(loggedInUser) },
434
569
  });
435
- // Saving bookmarked accounts separately.
570
+ // TODO: migrate to GraphQL - bookmark accounts skipped for now
436
571
  const canViewBookmarkAccounts = loggedInUser.isInternal;
437
572
  if (canViewBookmarkAccounts) {
438
573
  fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
@@ -455,16 +590,18 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
455
590
  });
456
591
  }
457
592
  });
458
- export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
593
+ export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
594
+ var _a;
595
+ dispatch({
596
+ type: GlobalMetadataReducerConstants.setCaseLanguages,
597
+ payload: { caseLanguages: getApiResourceObject([], true) },
598
+ });
459
599
  try {
600
+ const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
601
+ const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
460
602
  dispatch({
461
603
  type: GlobalMetadataReducerConstants.setCaseLanguages,
462
- payload: { caseLanguages: getApiResourceObject([], true) },
463
- });
464
- const response = yield caseMetadata.getLanguagesMetadata();
465
- dispatch({
466
- type: GlobalMetadataReducerConstants.setCaseLanguages,
467
- payload: { caseLanguages: getApiResourceObject(response.items) },
604
+ payload: { caseLanguages: getApiResourceObject(caseLanguages) },
468
605
  });
469
606
  }
470
607
  catch (e) {
@@ -512,7 +649,10 @@ export const fetchCaseSbrsMetadata = (dispatch) => __awaiter(void 0, void 0, voi
512
649
  });
513
650
  }
514
651
  });
515
- export const fetchCaseGroupsForSSO = (dispatch, ssoUserName) => __awaiter(void 0, void 0, void 0, function* () {
652
+ export const fetchCaseGroupsForSSO = (dispatch, ssoUserName, apolloClient, accountId, defaultCaseGroupId) => __awaiter(void 0, void 0, void 0, function* () {
653
+ if (apolloClient && accountId) {
654
+ return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId);
655
+ }
516
656
  try {
517
657
  dispatch({
518
658
  type: GlobalMetadataReducerConstants.setCaseGroups,
@@ -533,7 +673,10 @@ export const fetchCaseGroupsForSSO = (dispatch, ssoUserName) => __awaiter(void 0
533
673
  });
534
674
  }
535
675
  });
536
- export const fetchCaseGroupsForAccount = (dispatch, accountNumber) => __awaiter(void 0, void 0, void 0, function* () {
676
+ export const fetchCaseGroupsForAccount = (dispatch, accountNumber, apolloClient, accountId, defaultCaseGroupId) => __awaiter(void 0, void 0, void 0, function* () {
677
+ if (apolloClient && accountId) {
678
+ return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId);
679
+ }
537
680
  try {
538
681
  dispatch({
539
682
  type: GlobalMetadataReducerConstants.setCaseGroups,
@@ -553,7 +696,10 @@ export const fetchCaseGroupsForAccount = (dispatch, accountNumber) => __awaiter(
553
696
  });
554
697
  }
555
698
  });
556
- export const fetchCaseGroups = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
699
+ export const fetchCaseGroups = (dispatch, apolloClient, accountId, defaultCaseGroupId) => __awaiter(void 0, void 0, void 0, function* () {
700
+ if (apolloClient && accountId) {
701
+ return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId);
702
+ }
557
703
  try {
558
704
  dispatch({
559
705
  type: GlobalMetadataReducerConstants.setCaseGroups,
@@ -572,6 +718,45 @@ export const fetchCaseGroups = (dispatch) => __awaiter(void 0, void 0, void 0, f
572
718
  });
573
719
  }
574
720
  });
721
+ /** Shared implementation that fetches case groups via GraphQL by Salesforce Account ID. */
722
+ const fetchCaseGroupsByAccountId = (dispatch, apolloClient, accountId, defaultCaseGroupId) => __awaiter(void 0, void 0, void 0, function* () {
723
+ var _a, _b, _c;
724
+ try {
725
+ dispatch({
726
+ type: GlobalMetadataReducerConstants.setCaseGroups,
727
+ payload: { caseGroups: getApiResourceObject([], true) },
728
+ });
729
+ const { data } = yield apolloClient.query({
730
+ query: GET_CASE_GROUP,
731
+ variables: { where: { Account__c: { eq: accountId } }, first: 2000 },
732
+ fetchPolicy: 'network-only',
733
+ });
734
+ const edges = ((_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.SalesforceSupportCaseGroup__c) === null || _c === void 0 ? void 0 : _c.edges) || [];
735
+ const groups = edges.map(({ node }) => {
736
+ var _a;
737
+ return ({
738
+ groupNum: node.Id,
739
+ name: unescape((_a = node.Name.displayValue) !== null && _a !== void 0 ? _a : node.Name.value),
740
+ isPrivate: false,
741
+ isDefault: defaultCaseGroupId ? node.Id === defaultCaseGroupId : false,
742
+ defaultMembers: [],
743
+ members: [],
744
+ });
745
+ });
746
+ groups.sort((a, b) => a.name.localeCompare(b.name));
747
+ dispatch({
748
+ type: GlobalMetadataReducerConstants.setCaseGroups,
749
+ payload: { caseGroups: getApiResourceObject(groups, false) },
750
+ });
751
+ return groups;
752
+ }
753
+ catch (e) {
754
+ dispatch({
755
+ type: GlobalMetadataReducerConstants.setCaseGroups,
756
+ payload: { caseGroups: getApiResourceObject([], false, true, e.message) },
757
+ });
758
+ }
759
+ });
575
760
  export const setCaseGroups = (dispatch, groups) => {
576
761
  dispatch({
577
762
  type: GlobalMetadataReducerConstants.setCaseGroups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.276",
3
+ "version": "2.5.277",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -22,7 +22,8 @@
22
22
  "lib/**/*"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@cee-eng/hydrajs": "4.18.111",
25
+ "@apollo/client": "^4.1.6",
26
+ "@cee-eng/hydrajs": "^4.18.113",
26
27
  "@patternfly/react-core": "6.2.1",
27
28
  "@patternfly/react-icons": "6.2.1",
28
29
  "i18next": "^23.15.0",
@@ -33,13 +34,13 @@
33
34
  "react-test-renderer": "18.2.0"
34
35
  },
35
36
  "dependencies": {
36
- "@cee-eng/hydrajs": "4.18.111",
37
+ "@cee-eng/hydrajs": "^4.18.113",
37
38
  "@patternfly/react-core": "6.2.1",
38
39
  "@patternfly/react-icons": "6.2.1",
39
- "@rh-support/components": "2.5.182",
40
+ "@rh-support/components": "2.5.183",
40
41
  "@rh-support/types": "2.0.26",
41
- "@rh-support/user-permissions": "2.5.128",
42
- "@rh-support/utils": "2.5.92",
42
+ "@rh-support/user-permissions": "2.5.129",
43
+ "@rh-support/utils": "2.5.111",
43
44
  "i18next": "^23.15.0",
44
45
  "localforage": "^1.10.0",
45
46
  "lodash": "^4.17.21",
@@ -89,5 +90,5 @@
89
90
  "defaults and supports es6-module",
90
91
  "maintained node versions"
91
92
  ],
92
- "gitHead": "5a3a62786c13896575f6db3805b3a0dc0bd1299f"
93
+ "gitHead": "deb5936155a3b68fc98e231dde9819da0967876b"
93
94
  }
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtraPreChatInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ExtraPreChatInfo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;GA6B5B,CAAC"}
@@ -1,29 +0,0 @@
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
- ];
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePreChatFormDetails.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePreChatFormDetails.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,QAAO,CAAC,MAAM,mBAAmB,EAAE,CA+CpE,CAAC"}
@@ -1,61 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { publicApi } from '@cee-eng/hydrajs';
11
- import { useContext, useEffect, useState } from 'react';
12
- import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
13
- /**
14
- *
15
- * The use of this hook is to generate form details based on user current screen
16
- */
17
- export const usePreChatFormDetails = () => {
18
- const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
19
- const [sessionId, setSessionId] = useState('');
20
- const loggedInUserRightsData = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data;
21
- const ssoName = loggedInUserRightsData.getSSOUsername();
22
- const name = loggedInUserRightsData.getUserFullName();
23
- const accountNumber = loggedInUserRightsData.getAccountNumber();
24
- useEffect(() => {
25
- try {
26
- const fetchChatSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
27
- const { message } = yield publicApi.chat.getChatSession();
28
- setSessionId(message);
29
- });
30
- fetchChatSessionId();
31
- }
32
- catch (error) {
33
- console.log('Error', error);
34
- }
35
- }, []);
36
- const getChatFormDetails = () => [
37
- {
38
- label: 'SSO Name',
39
- value: ssoName,
40
- transcriptFields: ['SSO_Username__c'],
41
- displayToAgent: true,
42
- },
43
- {
44
- label: 'SessionId',
45
- value: sessionId,
46
- transcriptFields: ['SessionId__c'],
47
- displayToAgent: true,
48
- },
49
- {
50
- label: 'name',
51
- value: name,
52
- displayToAgent: true,
53
- },
54
- {
55
- label: 'account',
56
- value: accountNumber,
57
- displayToAgent: true,
58
- },
59
- ];
60
- return getChatFormDetails;
61
- };