@rh-support/troubleshoot 2.6.296 → 2.6.300

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 (106) hide show
  1. package/lib/esm/components/AccountInfo/AccountSelector.d.ts.map +1 -1
  2. package/lib/esm/components/AccountInfo/AccountSelector.js +40 -28
  3. package/lib/esm/components/CaseEditView/ActiveCustomerEscalation/RequestEscalationModal.d.ts.map +1 -1
  4. package/lib/esm/components/CaseEditView/ActiveCustomerEscalation/RequestEscalationModal.js +12 -42
  5. package/lib/esm/components/CaseEditView/Case.d.ts.map +1 -1
  6. package/lib/esm/components/CaseEditView/Case.js +5 -7
  7. package/lib/esm/components/CaseEditView/CaseDetailsAside.d.ts.map +1 -1
  8. package/lib/esm/components/CaseEditView/CaseDetailsAside.js +8 -25
  9. package/lib/esm/components/CaseEditView/CaseDetailsTabs.d.ts.map +1 -1
  10. package/lib/esm/components/CaseEditView/CaseDetailsTabs.js +10 -14
  11. package/lib/esm/components/CaseEditView/CaseOverview/index.d.ts.map +1 -1
  12. package/lib/esm/components/CaseEditView/CaseOverview/index.js +18 -24
  13. package/lib/esm/components/CaseEditView/RequestRemoteSession/NewEssTermsModal.d.ts.map +1 -1
  14. package/lib/esm/components/CaseEditView/RequestRemoteSession/NewEssTermsModal.js +6 -9
  15. package/lib/esm/components/CaseEditView/RequestRemoteSession/RemoteSessionAgreementModal.d.ts.map +1 -1
  16. package/lib/esm/components/CaseEditView/RequestRemoteSession/RemoteSessionAgreementModal.js +3 -7
  17. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/CaseContactPhoneNumber.d.ts.map +1 -1
  18. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/CaseContactPhoneNumber.js +34 -38
  19. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/CaseDetailsManagement.d.ts.map +1 -1
  20. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/CaseDetailsManagement.js +9 -9
  21. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/ProductVersion.d.ts.map +1 -1
  22. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/ProductVersion.js +59 -19
  23. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/Summary.d.ts.map +1 -1
  24. package/lib/esm/components/CaseEditView/Tabs/CaseDetails/Summary.js +9 -16
  25. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/VerifyCaseStatusModal/VerifyCaseStatusModal.d.ts.map +1 -1
  26. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/VerifyCaseStatusModal/VerifyCaseStatusModal.js +3 -5
  27. package/lib/esm/components/CaseEditView/Tabs/RMEEscalations/RMEEscalationList.d.ts.map +1 -1
  28. package/lib/esm/components/CaseEditView/Tabs/RMEEscalations/RMEEscalationList.js +2 -3
  29. package/lib/esm/components/CaseInformation/CaseInformation.d.ts.map +1 -1
  30. package/lib/esm/components/CaseInformation/CaseInformation.js +5 -7
  31. package/lib/esm/components/CaseInformation/ContactPhoneNumber.d.ts.map +1 -1
  32. package/lib/esm/components/CaseInformation/ContactPhoneNumber.js +24 -37
  33. package/lib/esm/components/CaseInformation/SupportLevel.d.ts.map +1 -1
  34. package/lib/esm/components/CaseInformation/SupportLevel.js +55 -32
  35. package/lib/esm/components/CaseManagement/CaseLanguageSelector.js +2 -2
  36. package/lib/esm/components/CaseManagement/CaseManagement.d.ts.map +1 -1
  37. package/lib/esm/components/CaseManagement/CaseManagement.js +9 -4
  38. package/lib/esm/components/IdeaInformation/IdeaInformation.d.ts.map +1 -1
  39. package/lib/esm/components/IdeaInformation/IdeaInformation.js +12 -11
  40. package/lib/esm/components/OpenCase/SupportTypeSelectorPage.d.ts.map +1 -1
  41. package/lib/esm/components/OpenCase/SupportTypeSelectorPage.js +2 -4
  42. package/lib/esm/components/ProductSelector/AllProductsSelector.d.ts +1 -0
  43. package/lib/esm/components/ProductSelector/AllProductsSelector.d.ts.map +1 -1
  44. package/lib/esm/components/ProductSelector/AllProductsSelector.js +15 -3
  45. package/lib/esm/components/ProductSelector/NewProductDropdownSelector.d.ts.map +1 -1
  46. package/lib/esm/components/ProductSelector/NewProductDropdownSelector.js +37 -13
  47. package/lib/esm/components/ProductSelector/NewProductVersionSelector.d.ts.map +1 -1
  48. package/lib/esm/components/ProductSelector/NewProductVersionSelector.js +53 -19
  49. package/lib/esm/components/ProductSelector/ProductSelector.d.ts.map +1 -1
  50. package/lib/esm/components/ProductSelector/ProductSelector.js +3 -1
  51. package/lib/esm/components/Review/Review.d.ts.map +1 -1
  52. package/lib/esm/components/Review/Review.js +18 -16
  53. package/lib/esm/components/SessionRestore/SessionRestore.d.ts.map +1 -1
  54. package/lib/esm/components/SessionRestore/SessionRestore.js +1 -3
  55. package/lib/esm/components/UpdateSeverityModal/UpdateSeverityModal.js +1 -1
  56. package/lib/esm/components/shared/useIsSectionValid.d.ts.map +1 -1
  57. package/lib/esm/components/shared/useIsSectionValid.js +64 -50
  58. package/lib/esm/components/wizardLayout/GlobalTroubleshootEffects.d.ts.map +1 -1
  59. package/lib/esm/components/wizardLayout/GlobalTroubleshootEffects.js +23 -106
  60. package/lib/esm/components/wizardLayout/WizardLayout.d.ts.map +1 -1
  61. package/lib/esm/components/wizardLayout/WizardLayout.js +7 -6
  62. package/lib/esm/components/wizardLayout/WizardNavigation.d.ts.map +1 -1
  63. package/lib/esm/components/wizardLayout/WizardNavigation.js +10 -10
  64. package/lib/esm/context/CaseContext.d.ts.map +1 -1
  65. package/lib/esm/hooks/useResetCaseCreate.d.ts.map +1 -1
  66. package/lib/esm/hooks/useResetCaseCreate.js +11 -18
  67. package/lib/esm/reducers/CaseConstNTypes.d.ts +2 -86
  68. package/lib/esm/reducers/CaseConstNTypes.d.ts.map +1 -1
  69. package/lib/esm/reducers/CaseConstNTypes.js +0 -5
  70. package/lib/esm/reducers/CaseDetailsPageReducer.d.ts +1 -3
  71. package/lib/esm/reducers/CaseDetailsPageReducer.d.ts.map +1 -1
  72. package/lib/esm/reducers/CaseDetailsPageReducer.js +5 -22
  73. package/lib/esm/reducers/CaseHelpers.d.ts +1 -2
  74. package/lib/esm/reducers/CaseHelpers.d.ts.map +1 -1
  75. package/lib/esm/reducers/CaseHelpers.js +2 -34
  76. package/lib/esm/reducers/CaseOverviewReducer.d.ts +1 -3
  77. package/lib/esm/reducers/CaseOverviewReducer.d.ts.map +1 -1
  78. package/lib/esm/reducers/CaseOverviewReducer.js +5 -7
  79. package/lib/esm/reducers/CaseReducer.d.ts +8 -27
  80. package/lib/esm/reducers/CaseReducer.d.ts.map +1 -1
  81. package/lib/esm/reducers/CaseReducer.js +29 -113
  82. package/package.json +6 -6
  83. package/lib/esm/graphql/index.d.ts +0 -4
  84. package/lib/esm/graphql/index.d.ts.map +0 -1
  85. package/lib/esm/graphql/index.js +0 -3
  86. package/lib/esm/graphql/mutations/createRMECaseEscalation.d.ts +0 -2
  87. package/lib/esm/graphql/mutations/createRMECaseEscalation.d.ts.map +0 -1
  88. package/lib/esm/graphql/mutations/createRMECaseEscalation.js +0 -24
  89. package/lib/esm/graphql/mutations/index.d.ts +0 -2
  90. package/lib/esm/graphql/mutations/index.d.ts.map +0 -1
  91. package/lib/esm/graphql/mutations/index.js +0 -1
  92. package/lib/esm/graphql/queries/getEscalationDetails.d.ts +0 -2
  93. package/lib/esm/graphql/queries/getEscalationDetails.d.ts.map +0 -1
  94. package/lib/esm/graphql/queries/getEscalationDetails.js +0 -24
  95. package/lib/esm/graphql/queries/getParentId.d.ts +0 -2
  96. package/lib/esm/graphql/queries/getParentId.d.ts.map +0 -1
  97. package/lib/esm/graphql/queries/getParentId.js +0 -16
  98. package/lib/esm/graphql/queries/index.d.ts +0 -3
  99. package/lib/esm/graphql/queries/index.d.ts.map +0 -1
  100. package/lib/esm/graphql/queries/index.js +0 -2
  101. package/lib/esm/graphql/schemas/escalation.d.ts +0 -84
  102. package/lib/esm/graphql/schemas/escalation.d.ts.map +0 -1
  103. package/lib/esm/graphql/schemas/escalation.js +0 -1
  104. package/lib/esm/graphql/schemas/index.d.ts +0 -2
  105. package/lib/esm/graphql/schemas/index.d.ts.map +0 -1
  106. package/lib/esm/graphql/schemas/index.js +0 -1
@@ -1,23 +1,32 @@
1
- // import { contacts } from '@cee-eng/hydrajs';
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 { contacts } from '@cee-eng/hydrajs';
2
11
  import { GlobalMetadataStateContext } from '@rh-support/react-context';
3
- // import find from 'lodash/find';
12
+ import find from 'lodash/find';
4
13
  import isEmpty from 'lodash/isEmpty';
5
14
  import isEqual from 'lodash/isEqual';
6
- import React, { useContext } from 'react';
7
- // import React, { useContext, useEffect, useState } from 'react';
15
+ import React, { useContext, useEffect, useState } from 'react';
8
16
  import { Trans } from 'react-i18next';
9
17
  import { useCaseSelector } from '../../context/CaseContext';
10
- import { RouteContext } from '../../context/RouteContext';
11
- // import { RouteContext, useRouteDispatchContext } from '../../context/RouteContext';
18
+ import { RouteContext, useRouteDispatchContext } from '../../context/RouteContext';
12
19
  import { TCStateContext } from '../../context/TopContentContext';
13
20
  import { useAB } from '../../hooks/useAB';
14
21
  import { CASE_DEATILS_ENVIRONMENT_LIMIT, CASE_REFERENCE_NUMBER_LIMIT, CONTACT_INFO_24X7_LIMIT, HOSTNAME_LENGTH_LIMIT, ISSUE_SUMMARY_LENGTH_LIMIT, KTQUESTION_MAX_LIMIT, TITLE_SUMMARY_LENGTH_LIMIT, } from '../../reducers/CaseConstNTypes';
15
22
  import { isCaseInformationSectionValid, isCaseManagementStateValid, isCaseStateValid, isClusterIDValid, isIdeaCaseStateValid, } from '../../reducers/CaseHelpers';
16
23
  import { AppRouteSections } from '../../reducers/RouteConstNTypes';
24
+ import { setNoValidEntitlement } from '../../reducers/RouteReducer';
17
25
  import { AttachmentStateContext } from './fileUpload/reducer/AttachmentReducerContext';
18
26
  export function useIsSectionValid(sectionName) {
27
+ var _a, _b;
19
28
  const { isVariationA } = useAB();
20
- const { caseState, caseType, product, version, contactSSOName, accountNumber, summary, hostname, contactInfo24x7, alternateId, selectedAccountDetails, issue, environment, timeFramesAndUrgency, periodicityOfIssue, manageSupportCases, } = useCaseSelector((state) => ({
29
+ const { caseState, caseType, product, version, contactSSOName, accountNumber, summary, hostname, contactInfo24x7, alternateId, selectedAccountDetails, issue, environment, timeFramesAndUrgency, periodicityOfIssue, ssoUsername, manageSupportCases, } = useCaseSelector((state) => ({
21
30
  caseState: state,
22
31
  caseType: state.caseDetails.caseType,
23
32
  product: state.caseDetails.product,
@@ -33,38 +42,35 @@ export function useIsSectionValid(sectionName) {
33
42
  environment: state.caseDetails.environment,
34
43
  timeFramesAndUrgency: state.caseDetails.timeFramesAndUrgency,
35
44
  periodicityOfIssue: state.caseDetails.periodicityOfIssue,
36
- // ssoUsername: state.selectedOwner.data.ssoUsername,
45
+ ssoUsername: state.selectedOwner.data.ssoUsername,
37
46
  manageSupportCases: state.selectedOwner.data.manageSupportCases,
38
47
  }), isEqual);
39
- // const routeDispatch = useRouteDispatchContext();
40
- // const [isEntitlement, setIsEntitlement] = useState<boolean | null>(null);
41
- // useEffect(() => {
42
- // const fetchContactDetails = async () => {
43
- // if (ssoUsername) {
44
- // try {
45
- // const response = await contacts.getSFDCContactBySso(ssoUsername);
46
- // setIsEntitlement(response?.isEntitled ?? null);
47
- // setNoValidEntitlement(routeDispatch, !response?.isEntitled);
48
- // } catch (error) {
49
- // console.error('Error fetching contact details:', error);
50
- // setIsEntitlement(null);
51
- // setNoValidEntitlement(routeDispatch, null);
52
- // }
53
- // }
54
- // };
55
- // fetchContactDetails();
56
- // }, [ssoUsername, routeDispatch]);
57
- // Contact-level entitlement hardcoded to true — now resolved from SFDCProductJSON__c
58
- const isEntitlement = true;
48
+ const routeDispatch = useRouteDispatchContext();
49
+ const [isEntitlement, setIsEntitlement] = useState(null);
50
+ useEffect(() => {
51
+ const fetchContactDetails = () => __awaiter(this, void 0, void 0, function* () {
52
+ var _a;
53
+ if (ssoUsername) {
54
+ try {
55
+ const response = yield contacts.getSFDCContactBySso(ssoUsername);
56
+ setIsEntitlement((_a = response === null || response === void 0 ? void 0 : response.isEntitled) !== null && _a !== void 0 ? _a : null);
57
+ setNoValidEntitlement(routeDispatch, !(response === null || response === void 0 ? void 0 : response.isEntitled));
58
+ }
59
+ catch (error) {
60
+ console.error('Error fetching contact details:', error);
61
+ setIsEntitlement(null);
62
+ setNoValidEntitlement(routeDispatch, null);
63
+ }
64
+ }
65
+ });
66
+ fetchContactDetails();
67
+ }, [ssoUsername, routeDispatch]);
68
+ //&seSessionId=8e8960ac-680b-443e-bf67-9e13f2acd64e
59
69
  const { routeState: { isCaseCreate }, } = useContext(RouteContext);
60
70
  const { globalMetadataState: { allProducts, loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
61
71
  const { topContentState: { topContent }, } = useContext(TCStateContext);
62
- // isEntitledProduct commented out; product-level entitlement now resolved from SFDCProductJSON__c
63
- // const isEntitledProduct = find(
64
- // allProducts?.data?.productsResult,
65
- // (p) => p.product === caseState.caseDetails.product
66
- // )?.isEntitledProduct;
67
- const { routeState: { activeSection }, } = useContext(RouteContext);
72
+ const isEntitledProduct = (_b = find((_a = allProducts === null || allProducts === void 0 ? void 0 : allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult, (p) => p.product === caseState.caseDetails.product)) === null || _b === void 0 ? void 0 : _b.isEntitledProduct;
73
+ const { routeState: { activeSection, isSearchIntent }, } = useContext(RouteContext);
68
74
  const { attachmentState } = useContext(AttachmentStateContext);
69
75
  const selectedLocalFiles = attachmentState.caseFiles.selectedLocalFiles;
70
76
  const allowedTypesIdea = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'];
@@ -105,6 +111,8 @@ export function useIsSectionValid(sectionName) {
105
111
  }
106
112
  return (!isEmpty(product) &&
107
113
  !isEmpty(version) &&
114
+ !isEmpty(accountNumber) &&
115
+ !isEmpty(contactSSOName) &&
108
116
  !isEmpty(summary) &&
109
117
  (summary === null || summary === void 0 ? void 0 : summary.length) <= TITLE_SUMMARY_LENGTH_LIMIT &&
110
118
  !isEmpty(issue) &&
@@ -121,22 +129,23 @@ export function useIsSectionValid(sectionName) {
121
129
  };
122
130
  const isResourcesSectionValid = () => {
123
131
  var _a;
124
- // isEntitledProduct check removed product-level entitlement now resolved from SFDCProductJSON__c
132
+ // don't check for entitled product if user is on search intent flow
133
+ const isEntitledProductLocal = isSearchIntent ? true : isEntitledProduct;
134
+ // Skip cluster ID validation for Variant A
125
135
  const clusterIdValid = isVariationA ? true : isClusterIDValid(caseState, (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult);
126
- return clusterIdValid;
136
+ return isEntitledProductLocal && clusterIdValid;
127
137
  };
128
138
  const isReviewSectionValid = () => {
129
139
  var _a;
130
- return (
131
- // isEntitledProduct — product-level entitlement now resolved from SFDCProductJSON__c
132
- isCaseStateValid(caseState, loggedInUserRights) &&
140
+ return (isEntitledProduct &&
141
+ isCaseStateValid(caseState, loggedInUserRights) &&
133
142
  isClusterIDValid(caseState, (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult) &&
134
143
  isSummarizeSectionValid() &&
135
144
  isAdditionalInformationSectionValidLocal());
136
145
  };
137
146
  const isDescribeIdeaSectionValid = () => {
138
147
  return (isCaseManagementStateValid(caseState, loggedInUserRights) &&
139
- // isEntitledProduct — product-level entitlement now resolved from SFDCProductJSON__c
148
+ isEntitledProduct &&
140
149
  isIdeaCaseStateValid(caseState, loggedInUserRights) &&
141
150
  checkUnallowedFiles());
142
151
  };
@@ -176,8 +185,14 @@ export function useIsSectionValid(sectionName) {
176
185
  }
177
186
  };
178
187
  const recommendationSectionError = () => {
179
- // isEntitledProduct check removed — product-level entitlement now resolved from SFDCProductJSON__c
180
- return '';
188
+ if (!product)
189
+ return '';
190
+ const isEntitledProductLocal = isSearchIntent ? true : isEntitledProduct;
191
+ return !isEntitledProductLocal ? (React.createElement(Trans, { i18nKey: "i18ValidEntitlementContactCustomerService" },
192
+ "You need a valid entitlement to create a case.\u00A0 Please contact",
193
+ ' ',
194
+ React.createElement("a", { href: "/support/contact/customerService" }, "Customer Service"),
195
+ " for assistance.")) : ('');
181
196
  };
182
197
  const getSupportSectionError = () => {
183
198
  if (manageSupportCases === false) {
@@ -187,14 +202,13 @@ export function useIsSectionValid(sectionName) {
187
202
  React.createElement("a", { href: "/support/contact/customerService" }, "Customer Service"),
188
203
  " for assistance."));
189
204
  }
190
- // if (isEntitlement === false) {
191
- // return (
192
- // <Trans i18nKey="i18ValidEntitlementContactCustomerService">
193
- // You need a valid entitlement to create a case.&nbsp; Please contact{' '}
194
- // <a href="/support/contact/customerService">Customer Service</a> for assistance.
195
- // </Trans>
196
- // );
197
- // }
205
+ if (isEntitlement === false) {
206
+ return (React.createElement(Trans, { i18nKey: "i18ValidEntitlementContactCustomerService" },
207
+ "You need a valid entitlement to create a case.\u00A0 Please contact",
208
+ ' ',
209
+ React.createElement("a", { href: "/support/contact/customerService" }, "Customer Service"),
210
+ " for assistance."));
211
+ }
198
212
  return '';
199
213
  };
200
214
  const activeSectionError = (sectionNameLocal) => {
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAWvD,OAAO,EAAuC,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAYvG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,qBA4atD"}
1
+ {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AASA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAWvD,OAAO,EAAuC,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAYvG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,qBAgUtD"}
@@ -7,11 +7,9 @@ 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 { useDebounce } from '@rh-support/components';
12
11
  import { GlobalMetadataStateContext, useUserPreferences } from '@rh-support/react-context';
13
12
  import { ability, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
14
- import { GET_ACCOUNT_CONTACTS, resolveProductServiceLevelsForAccount, } from '@rh-support/utils';
15
13
  import findIndex from 'lodash/findIndex';
16
14
  import includes from 'lodash/includes';
17
15
  import isEmpty from 'lodash/isEmpty';
@@ -25,7 +23,7 @@ import { TCDispatchContext, TCStateContext } from '../../context/TopContentConte
25
23
  import { useResetCaseCreate } from '../../hooks/useResetCaseCreate';
26
24
  import { CASE_DEATILS_SOURCE_REFERRER_LIMIT } from '../../reducers/CaseConstNTypes';
27
25
  import { getDescriptionWOQues } from '../../reducers/CaseHelpers';
28
- import { setCaseAccountNumber, setCaseDetails, setCaseOwner, setCaseState } from '../../reducers/CaseReducer';
26
+ import { setCaseAccountNumber, setCaseDetails, setCaseOwner } from '../../reducers/CaseReducer';
29
27
  import { AppRouteSections } from '../../reducers/RouteConstNTypes';
30
28
  import { setActiveSectionChanged, setRouteFlags, updateisNextBtnClickedToShowValidationError, } from '../../reducers/RouteReducer';
31
29
  import { fetchEdmundAbbottRules } from '../../reducers/RulesReducer';
@@ -36,28 +34,23 @@ import { AttachmentStateContext } from '../shared/fileUpload/reducer/AttachmentR
36
34
  export function GlobalTroubleshootEffects(props) {
37
35
  const [initDefaultSection, setInitDefaultSection] = useState(false);
38
36
  const dispatchToRouteReducer = useContext(RouteDispatchContext);
39
- const { globalMetadataState: { allProducts, loggedInUser, managedAccounts, loggedInUserRights, loggedInUsersAccount, loggedInUserJwtToken, }, } = useContext(GlobalMetadataStateContext);
37
+ const { globalMetadataState: { allProducts, loggedInUser, managedAccounts, loggedInUserRights, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
40
38
  const { sessionRestore: { activeSessionId }, } = useContext(SessionRestoreStateContext);
41
- const { accountNumber, contactSsoUsername, product, version, summary, issue, environment, periodicityOfIssue, timeFramesAndUrgency, caseType, language, selectedAccountDetails, selectedOwnerContactId, } = useCaseSelector((state) => {
42
- var _a, _b;
43
- return ({
44
- accountNumber: state.caseDetails.accountNumberRef,
45
- contactSsoUsername: state.caseDetails.contactSSOName,
46
- product: state.caseDetails.product,
47
- version: state.caseDetails.version,
48
- summary: state.caseDetails.summary,
49
- issue: state.caseDetails.issue,
50
- environment: state.caseDetails.environment,
51
- periodicityOfIssue: state.caseDetails.periodicityOfIssue,
52
- timeFramesAndUrgency: state.caseDetails.timeFramesAndUrgency,
53
- caseType: state.caseDetails.caseType,
54
- language: state.caseDetails.caseLanguage,
55
- selectedAccountDetails: state.selectedAccountDetails,
56
- selectedOwnerContactId: (_b = (_a = state.selectedOwner) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.id,
57
- });
58
- }, isEqual);
39
+ const { accountNumber, product, version, contactSsoUsername, summary, issue, environment, periodicityOfIssue, timeFramesAndUrgency, caseType, language, selectedAccountDetails, } = useCaseSelector((state) => ({
40
+ accountNumber: state.caseDetails.accountNumberRef,
41
+ product: state.caseDetails.product,
42
+ version: state.caseDetails.version,
43
+ contactSsoUsername: state.caseDetails.contactSSOName,
44
+ summary: state.caseDetails.summary,
45
+ issue: state.caseDetails.issue,
46
+ environment: state.caseDetails.environment,
47
+ periodicityOfIssue: state.caseDetails.periodicityOfIssue,
48
+ timeFramesAndUrgency: state.caseDetails.timeFramesAndUrgency,
49
+ caseType: state.caseDetails.caseType,
50
+ language: state.caseDetails.caseLanguage,
51
+ selectedAccountDetails: state.selectedAccountDetails,
52
+ }), isEqual);
59
53
  const caseDispatch = useCaseDispatch();
60
- const apolloClient = useApolloClient();
61
54
  const isCaseCreate = RouteUtils.getQueryParams(props.routeProps).caseCreate === 'true';
62
55
  const urlQueryParams = RouteUtils.getQueryParams(props.routeProps);
63
56
  const isFirstMount = useRef(true);
@@ -162,78 +155,20 @@ export function GlobalTroubleshootEffects(props) {
162
155
  // eslint-disable-next-line react-hooks/exhaustive-deps
163
156
  }, [dispatchToRouteReducer, props.routeProps.location.pathname, isCaseCreate, isSearchIntent]);
164
157
  /**
165
- * Auto-populate account and owner for external users.
166
- * For org admin: dropdowns are visible but disabled sets initial values.
167
- * For non-org admin: dropdowns are hidden fires the same queries in background.
158
+ * Setting Default AccountNumber and ContactSsoUsername from loggedInUsersAccount
159
+ * Disabling exhaustive-deps rule as we don't want to reset default values if user manually clears these from UI.
160
+ * This is a one time thing when loggedInUserJwtToken is set.
168
161
  */
169
162
  useEffect(() => {
170
- var _a, _b;
171
163
  if (!isCaseCreate)
172
164
  return;
173
- if (isEmpty(loggedInUserRights.data))
174
- return;
175
- if (loggedInUserRights.data.isInternal())
176
- return;
177
- const resolvedAccountNumber = ((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.accountNumber) ||
178
- loggedInUserRights.data.getAccountNumber() ||
179
- (loggedInUserJwtToken === null || loggedInUserJwtToken === void 0 ? void 0 : loggedInUserJwtToken.account_number) ||
180
- '';
181
- if (isEmpty(accountNumber) && !isEmpty(resolvedAccountNumber)) {
182
- const hasFullAccountData = !isEmpty((_b = loggedInUsersAccount.data) === null || _b === void 0 ? void 0 : _b.accountNumber);
183
- setCaseAccountNumber(caseDispatch, resolvedAccountNumber, hasFullAccountData, hasFullAccountData ? loggedInUsersAccount.data : {}, apolloClient);
184
- }
185
- if (isEmpty(contactSsoUsername)) {
165
+ isEmpty(accountNumber) && setCaseAccountNumber(caseDispatch, loggedInUserRights.data.getAccountNumber());
166
+ isEmpty(contactSsoUsername) &&
186
167
  setCaseOwner(caseDispatch, loggedInUserRights.data.getHydraContactFromLoggedInUser(), product, undefined, undefined, true, undefined, true, undefined, undefined, loggedInUserRights.data.isInternal()
187
168
  ? accountNumber || loggedInUserRights.data.getAccountNumber()
188
169
  : undefined);
189
- }
190
170
  // eslint-disable-next-line react-hooks/exhaustive-deps
191
- }, [
192
- caseDispatch,
193
- loggedInUserRights.data,
194
- loggedInUsersAccount.data,
195
- apolloClient,
196
- accountNumber,
197
- contactSsoUsername,
198
- ]);
199
- useEffect(() => {
200
- if (isEmpty(loggedInUserRights.data) || loggedInUserRights.data.isInternal())
201
- return;
202
- if (isEmpty(accountNumber) || isEmpty(contactSsoUsername))
203
- return;
204
- if (selectedAccountDetails.isFetching)
205
- return;
206
- if (selectedOwnerContactId)
207
- return;
208
- const ownerSso = loggedInUserRights.data.getSSOUsername();
209
- const fetchContacts = () => __awaiter(this, void 0, void 0, function* () {
210
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
211
- try {
212
- const { data } = yield apolloClient.query({
213
- query: GET_ACCOUNT_CONTACTS,
214
- variables: {
215
- accountNumber: { eq: accountNumber },
216
- first: 200,
217
- orderBy: { Name: { order: 'ASC' } },
218
- },
219
- });
220
- const response = data;
221
- const contactEdges = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.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 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.node) === null || _f === void 0 ? void 0 : _f.Contacts) === null || _g === void 0 ? void 0 : _g.edges) !== null && _h !== void 0 ? _h : [];
222
- const matchingContact = contactEdges.find(({ node }) => { var _a, _b; return ((_b = (_a = node.SSOUserName__c) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === (ownerSso === null || ownerSso === void 0 ? void 0 : ownerSso.toLowerCase()); });
223
- if ((_j = matchingContact === null || matchingContact === void 0 ? void 0 : matchingContact.node) === null || _j === void 0 ? void 0 : _j.Id) {
224
- const ownerWithId = Object.assign(Object.assign({}, loggedInUserRights.data.getHydraContactFromLoggedInUser()), { id: matchingContact.node.Id });
225
- setCaseState(caseDispatch, {
226
- selectedOwner: { data: ownerWithId, isFetching: false, isError: false, errorMessage: '' },
227
- });
228
- }
229
- }
230
- catch (e) {
231
- // Contact fetch failed; case proceeds with owner from JWT
232
- }
233
- });
234
- fetchContacts();
235
- // eslint-disable-next-line react-hooks/exhaustive-deps
236
- }, [accountNumber, contactSsoUsername, selectedAccountDetails.isFetching, selectedOwnerContactId]);
171
+ }, [caseDispatch, loggedInUserRights.data]);
237
172
  /**
238
173
  * handling top content call
239
174
  */
@@ -245,22 +180,6 @@ export function GlobalTroubleshootEffects(props) {
245
180
  return;
246
181
  fetchTopContent(tcDispatch, { product, version });
247
182
  }, [product, tcDispatch, topContentPayload, version]);
248
- useEffect(() => {
249
- if (isEmpty(product) || selectedAccountDetails.isFetching || isEmpty(selectedAccountDetails.data))
250
- return;
251
- const serviceLevels = resolveProductServiceLevelsForAccount(selectedAccountDetails.data, allProducts.data.productsResult, product);
252
- if (!serviceLevels)
253
- return;
254
- setCaseState(caseDispatch, {
255
- productServiceLevel: serviceLevels.productServiceLevel,
256
- otherServiceLevels: serviceLevels.otherServiceLevels,
257
- selectedEntitlementId: serviceLevels.defaultEntitlementId,
258
- });
259
- if (serviceLevels.entitlementSla) {
260
- setCaseDetails(caseDispatch, { entitlementSla: serviceLevels.entitlementSla });
261
- }
262
- // eslint-disable-next-line react-hooks/exhaustive-deps
263
- }, [product, selectedAccountDetails.data, allProducts.data.productsResult]);
264
183
  // set case language to preferred language
265
184
  useEffect(() => {
266
185
  const userOriginalPreferredLanguage = () => __awaiter(this, void 0, void 0, function* () {
@@ -337,13 +256,11 @@ export function GlobalTroubleshootEffects(props) {
337
256
  * each case create. Currently we refetch the account details when user clicks on troubleshoot a new session
338
257
  */
339
258
  useEffect(() => {
340
- if (loggedInUserRights.data.isInternal())
341
- return;
342
259
  if (!isEmpty(loggedInUsersAccount.data) &&
343
260
  !isEmpty(selectedAccountDetails.data) &&
344
261
  loggedInUserRights.data.isAccountSameAsLoggedInAccount(selectedAccountDetails.data.accountNumber) &&
345
262
  !isEqual(loggedInUsersAccount.data, selectedAccountDetails.data)) {
346
- setCaseAccountNumber(caseDispatch, loggedInUsersAccount.data.accountNumber, true, loggedInUsersAccount.data, apolloClient);
263
+ setCaseAccountNumber(caseDispatch, loggedInUsersAccount.data.accountNumber, true, loggedInUsersAccount.data);
347
264
  }
348
265
  // eslint-disable-next-line react-hooks/exhaustive-deps
349
266
  }, [loggedInUsersAccount.data]);
@@ -1 +1 @@
1
- {"version":3,"file":"WizardLayout.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/WizardLayout.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAuC,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAcvG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAoLzC"}
1
+ {"version":3,"file":"WizardLayout.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/WizardLayout.tsx"],"names":[],"mappings":"AASA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAuC,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAcvG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAqLzC"}
@@ -7,7 +7,6 @@ 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 { Grid, GridItem } from '@patternfly/react-core';
12
11
  import { SupportFeedbackForm } from '@rh-support/components';
13
12
  import { fetchProducts, GlobalMetadataDispatchContext, GlobalMetadataStateContext } from '@rh-support/react-context';
@@ -38,9 +37,10 @@ export function WizardLayout(props) {
38
37
  const { routeState: { activeSection, isCaseCreate }, } = useContext(RouteContext);
39
38
  const { getMetadata } = useMetadata();
40
39
  const [isAIChatMode, setIsAIChatMode] = useState(false);
41
- const { caseCreationError, caseType, product, caseState, hasInvalidEntitlements } = useCaseSelector((state) => ({
40
+ const { caseCreationError, contactSSOName, caseType, product, caseState, hasInvalidEntitlements } = useCaseSelector((state) => ({
42
41
  caseState: state,
43
42
  caseCreationError: state.caseCreationError,
43
+ contactSSOName: state.caseDetails.contactSSOName,
44
44
  caseType: state.caseDetails.caseType,
45
45
  product: state.caseDetails.product,
46
46
  hasInvalidEntitlements: state.hasInvalidEntitlements,
@@ -50,7 +50,6 @@ export function WizardLayout(props) {
50
50
  const { sessionRestore: { activeSessionId, previousSessions }, } = useContext(SessionRestoreStateContext);
51
51
  const { globalMetadataState: { allProducts, loggedInUser, loggedInUsersAccount, loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
52
52
  const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
53
- const apolloClient = useApolloClient();
54
53
  const canAddAttachments = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.ATTACHMENTS);
55
54
  const { attachmentState } = useContext(AttachmentStateContext);
56
55
  const isAnyFileAttachedLocal = isAnyFileAttached(attachmentState.caseFiles.selectedLocalFiles);
@@ -102,7 +101,7 @@ export function WizardLayout(props) {
102
101
  "Try submitting again after a minute. Please ",
103
102
  React.createElement(SupportFeedbackForm, { isInline: true }),
104
103
  " if you continue to see this message.")));
105
- submitCase(caseDispatch, sessionRestoreDispatch, caseState, isCaseCreate, errorMessageCaseSubmit500, loggedInUser.data.ssoUsername, loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data.secureSupport, isReSubmitting || false, RouteUtils.getQueryParams(props.routeProps).caseCreate === 'true', sessionItem, apolloClient);
104
+ submitCase(caseDispatch, sessionRestoreDispatch, caseState, isCaseCreate, errorMessageCaseSubmit500, loggedInUser.data.ssoUsername, loggedInUsersAccount === null || loggedInUsersAccount === void 0 ? void 0 : loggedInUsersAccount.data.secureSupport, isReSubmitting || false, RouteUtils.getQueryParams(props.routeProps).caseCreate === 'true', sessionItem);
106
105
  // reset viewedModals on case submit
107
106
  viewedConfirmationModalsList.current = [];
108
107
  !isReSubmitting &&
@@ -121,9 +120,11 @@ export function WizardLayout(props) {
121
120
  }
122
121
  setConfirmationModalType(null);
123
122
  };
123
+ // Loading app metadata
124
124
  useEffect(() => {
125
- fetchProducts(dispatchToGlobalMetadataReducer, apolloClient);
126
- }, [dispatchToGlobalMetadataReducer, apolloClient]);
125
+ fetchProducts(dispatchToGlobalMetadataReducer, contactSSOName);
126
+ // eslint-disable-next-line react-hooks/exhaustive-deps
127
+ }, [contactSSOName, dispatchToGlobalMetadataReducer]);
127
128
  return (React.createElement(React.Fragment, null,
128
129
  React.createElement(GlobalTroubleshootEffects, { routeProps: props.routeProps }),
129
130
  activeSection !== AppRouteSections.DESCRIBE_IDEA && (React.createElement(PreCaseConfirmationModals, { onModalClose: onModalClose, confirmationModalType: confirmationModalType, onConfirm: () => submitCaseAndNavigate(caseCreationError) })),
@@ -1 +1 @@
1
- {"version":3,"file":"WizardNavigation.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/WizardNavigation.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAoB,eAAe,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAM3G,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACzD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,mBAAmB,EAAE,CAAC,gCAAgC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzE,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC5E,kCAAkC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACpF,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,gCAAgC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACjF,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAGD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,qBA8atC;kBA9aQ,gBAAgB;;;AAgbzB,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"WizardNavigation.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/WizardNavigation.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAoB,eAAe,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAM3G,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACzD,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,mBAAmB,EAAE,CAAC,gCAAgC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzE,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC5E,kCAAkC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACpF,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,gCAAgC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACjF,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAGD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,qBAmbtC;kBAnbQ,gBAAgB;;;AAqbzB,eAAe,gBAAgB,CAAC"}
@@ -12,6 +12,7 @@ import { Button, ButtonVariant, WizardFooterWrapper } from '@patternfly/react-co
12
12
  import { useFetch, usePrevious } from '@rh-support/components';
13
13
  import { GlobalMetadataStateContext, useCanCreateCase } from '@rh-support/react-context';
14
14
  import { dtmTrackEventCaseCreationStepEncountered, getResTypeFromUrl, isFunctionalCookieAccepted, PreviousToNewCaseTypeMap, scrollIntoView, } from '@rh-support/utils';
15
+ import find from 'lodash/find';
15
16
  import isEmpty from 'lodash/isEmpty';
16
17
  import isEqual from 'lodash/isEqual';
17
18
  import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
@@ -31,15 +32,14 @@ import { RecommendationFeedbackModal } from '../Recommendations/RecommendationFe
31
32
  import { useIsSectionValid } from '../shared/useIsSectionValid';
32
33
  const defaultProps = {};
33
34
  function WizardNavigation(props) {
35
+ var _a, _b;
34
36
  const { t } = useTranslation();
35
37
  const { isVariationA } = useAB();
36
38
  const canCreateCase = useCanCreateCase();
37
39
  const { recommendationState } = useContext(RecommendationStateContext);
38
40
  const aiResponseState = useAIResponseState();
39
- const { routeState: { activeSection, isNextBtnClickedToShowValidationError,
40
- // noValidEntitlement,
41
- isCaseCreate, }, } = useContext(RouteContext);
42
- const { globalMetadataState: { loggedInUsersAccount, navBarRef }, } = useContext(GlobalMetadataStateContext);
41
+ const { routeState: { activeSection, isNextBtnClickedToShowValidationError, noValidEntitlement, isSearchIntent, isCaseCreate, }, } = useContext(RouteContext);
42
+ const { globalMetadataState: { loggedInUsersAccount, allProducts, navBarRef }, } = useContext(GlobalMetadataStateContext);
43
43
  const { caseState, issue, summary, product, version, caseType } = useCaseSelector((state) => ({
44
44
  caseState: state,
45
45
  issue: state.caseDetails.issue,
@@ -49,11 +49,8 @@ function WizardNavigation(props) {
49
49
  caseType: state.caseDetails.caseType,
50
50
  manageSupportCases: state.selectedOwner.data.manageSupportCases,
51
51
  }), isEqual);
52
- // isEntitledProduct commented out; product-level entitlement now resolved from SFDCProductJSON__c
53
- // const isEntitledProduct = find(
54
- // allProducts?.data?.productsResult,
55
- // (p) => p.product === caseState.caseDetails.product
56
- // )?.isEntitledProduct;
52
+ // To check if the user is entitled or not
53
+ const isEntitledProduct = (_b = find((_a = allProducts === null || allProducts === void 0 ? void 0 : allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult, (p) => p.product === caseState.caseDetails.product)) === null || _b === void 0 ? void 0 : _b.isEntitledProduct;
57
54
  const dispatchToRouteReducer = useContext(RouteDispatchContext);
58
55
  const { activeSectionError, isSectionValidFn } = useIsSectionValid(activeSection);
59
56
  const [isRecsModalVisible, setIsRecsModalVisible] = useState(false);
@@ -254,6 +251,7 @@ function WizardNavigation(props) {
254
251
  }
255
252
  catch (e) { }
256
253
  });
254
+ const isEntitledProductLocal = isSearchIntent ? true : isEntitledProduct;
257
255
  const nextButtonDisabledLogic = () => {
258
256
  const isLoadingARH = props.isLoadingARH &&
259
257
  props.activeStep.id === AppRouteSections.RESOURCES &&
@@ -265,9 +263,11 @@ function WizardNavigation(props) {
265
263
  let value = isLoadingARH ||
266
264
  ((isEmpty(summary) || isEmpty(issue) || isEmpty(product) || isEmpty(version)) &&
267
265
  props.activeStep.id === (isCaseCreate ? AppRouteSections.SUMMARIZE : AppRouteSections.TROUBLESHOOT)) ||
266
+ (!isEntitledProductLocal && props.activeStep.nextButtonLabel === 'Get support') ||
268
267
  props.activeStep.nextButtonLabel === 'Troubleshoot' ||
268
+ !!activeSectionError ||
269
269
  (isSectionValidFn && !isSectionValidFn(props.activeStep.id) && isNextBtnClickedToShowValidationError) ||
270
- // noValidEntitlement ||
270
+ noValidEntitlement ||
271
271
  isLoadingRecs;
272
272
  return value;
273
273
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CaseContext.d.ts","sourceRoot":"","sources":["../../../src/context/CaseContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAqE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGxH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAoB,MAAM,6BAA6B,CAAC;AAK5F,eAAO,MAAM,gBAAgB,oEAAiF,CAAC;AAC/G,eAAO,MAAM,YAAY,0DAAiE,CAAC;AAE3F,eAAO,MAAM,eAAe,iDAAoE,CAAC;AACjG,eAAO,MAAM,eAAe,iJAAoE,CAAC;AAGjG,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE;;CAAA,qBAM/C"}
1
+ {"version":3,"file":"CaseContext.d.ts","sourceRoot":"","sources":["../../../src/context/CaseContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAqE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGxH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAoB,MAAM,6BAA6B,CAAC;AAK5F,eAAO,MAAM,gBAAgB,oEAAiF,CAAC;AAC/G,eAAO,MAAM,YAAY,0DAAiE,CAAC;AAC3F,eAAO,MAAM,eAAe,iDAAoE,CAAC;AACjG,eAAO,MAAM,eAAe,iJAAoE,CAAC;AAGjG,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE;;CAAA,qBAM/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useResetCaseCreate.d.ts","sourceRoot":"","sources":["../../../src/hooks/useResetCaseCreate.tsx"],"names":[],"mappings":"AAcA,wBAAgB,kBAAkB;;EAsCjC"}
1
+ {"version":3,"file":"useResetCaseCreate.d.ts","sourceRoot":"","sources":["../../../src/hooks/useResetCaseCreate.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,kBAAkB;;EA2CjC"}
@@ -1,3 +1,4 @@
1
+ import { fetchLoggedInUser, fetchLoggedInUsersAccount, GlobalMetadataDispatchContext, GlobalMetadataStateContext, } from '@rh-support/react-context';
1
2
  import { useContext } from 'react';
2
3
  import { AttachmentDispatchContext, resetAttachment } from '../components/shared/fileUpload';
3
4
  import { useCaseDispatch } from '../context/CaseContext';
@@ -6,6 +7,7 @@ import { useRecommendationDispatchContext } from '../context/RecommendationConte
6
7
  import { RulesDispatchContext } from '../context/RulesContext';
7
8
  import { TCDispatchContext } from '../context/TopContentContext';
8
9
  import { CaseReducerConstants } from '../reducers/CaseConstNTypes';
10
+ import { setCaseAccountNumber, setCaseOwner } from '../reducers/CaseReducer';
9
11
  import { resetClusterRecommendations } from '../reducers/ClusterRecommendationsReducer';
10
12
  import { resetRecommendations } from '../reducers/RecommendationsReducer';
11
13
  import { resetEARules } from '../reducers/RulesReducer';
@@ -15,31 +17,22 @@ export function useResetCaseCreate() {
15
17
  const tcDispatch = useContext(TCDispatchContext);
16
18
  const recommendationsDispatch = useRecommendationDispatchContext();
17
19
  const caseDispatch = useCaseDispatch();
20
+ const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
18
21
  const rulesDispatch = useContext(RulesDispatchContext);
19
22
  const clusterRecommendationsDispatch = useContext(ClusterRecommendationsDispatchContext);
23
+ const { globalMetadataState: { loggedInUsersAccount, loggedInUserRights, loggedInUserJwtToken }, } = useContext(GlobalMetadataStateContext);
20
24
  const resetCaseCreateState = () => {
21
- // Commented out don't refetch logged-in user contact details on case creation
22
- // fetchLoggedInUser(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, {});
25
+ // On case creation we refetch the user contact details to get users updated phone number
26
+ fetchLoggedInUser(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, {});
23
27
  resetAttachment(dispatchToAttachmentReducer);
24
28
  resetTopContent(tcDispatch);
25
29
  resetRecommendations(recommendationsDispatch);
26
30
  caseDispatch({ type: CaseReducerConstants.resetCaseState });
27
- // Commented out don't refetch account details or auto-populate account/owner on case creation
28
- // fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true, apolloClient);
29
- // setCaseAccountNumber(caseDispatch, loggedInUserRights.data.getAccountNumber(), true, loggedInUsersAccount.data);
30
- // setCaseOwner(
31
- // caseDispatch,
32
- // loggedInUserRights.data.getHydraContactFromLoggedInUser(),
33
- // '',
34
- // undefined,
35
- // undefined,
36
- // true,
37
- // undefined,
38
- // true,
39
- // undefined,
40
- // undefined,
41
- // loggedInUserRights.data.isInternal() ? loggedInUserRights.data.getAccountNumber() : undefined
42
- // );
31
+ // on case creation we refetch the account details to check if user still has all valid
32
+ // access for next case creation. For ex. may be user has exhausted his available enhanced sla limit
33
+ fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true);
34
+ setCaseAccountNumber(caseDispatch, loggedInUserRights.data.getAccountNumber(), true, loggedInUsersAccount.data);
35
+ setCaseOwner(caseDispatch, loggedInUserRights.data.getHydraContactFromLoggedInUser(), '', undefined, undefined, true, undefined, true, undefined, undefined, loggedInUserRights.data.isInternal() ? loggedInUserRights.data.getAccountNumber() : undefined);
43
36
  resetEARules(rulesDispatch);
44
37
  resetClusterRecommendations(clusterRecommendationsDispatch);
45
38
  };