@zeniai/client-epic-state 4.19.96-betaSS2 → 4.19.97-betaRR0

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 (146) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/entity/aiCfo/aiCfoSelector.d.ts +2 -1
  3. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -38
  5. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -78
  6. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +1 -4
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.js +1 -5
  8. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -37
  9. package/lib/entity/tenant/tenantPayload.d.ts +0 -1
  10. package/lib/entity/tenant/tenantReducer.js +0 -1
  11. package/lib/entity/tenant/tenantSelector.d.ts +0 -1
  12. package/lib/entity/tenant/tenantSelector.js +1 -9
  13. package/lib/entity/tenant/tenantState.d.ts +0 -1
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +1 -4
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  16. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -3
  17. package/lib/entity/transaction/payloadTypes/transactionPayload.js +0 -11
  18. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -1
  19. package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -3
  20. package/lib/entity/transaction/stateTypes/transactionLine.d.ts +1 -1
  21. package/lib/epic.d.ts +6 -2
  22. package/lib/epic.js +6 -2
  23. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -78
  24. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +1 -5
  25. package/lib/esm/entity/tenant/tenantReducer.js +0 -1
  26. package/lib/esm/entity/tenant/tenantSelector.js +0 -7
  27. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  28. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +0 -11
  29. package/lib/esm/epic.js +6 -2
  30. package/lib/esm/index.js +12 -10
  31. package/lib/esm/reducer.js +3 -0
  32. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -82
  33. package/lib/esm/view/aiCfoView/aiCfoViewSelector.js +2 -8
  34. package/lib/esm/view/classList/fetchClassListEpic.js +2 -9
  35. package/lib/esm/view/commonVendorView/vendorView/vendorViewSelector.js +5 -15
  36. package/lib/esm/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.js +2 -6
  37. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  38. package/lib/esm/view/expenseAutomationView/helpers/saveTransactionHelper.js +2 -2
  39. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  40. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -17
  41. package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  42. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +6 -61
  43. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +4 -12
  44. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  45. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -12
  46. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -17
  47. package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  48. package/lib/esm/view/spendManagement/billPay/billList/billListState.js +0 -1
  49. package/lib/esm/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +3 -7
  50. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +5 -5
  51. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPayApproversDetailsEpic.js +2 -7
  52. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +6 -13
  53. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +58 -0
  54. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +1 -0
  55. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +103 -0
  56. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +63 -0
  57. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +5 -0
  58. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +62 -0
  59. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +4 -0
  60. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +4 -0
  61. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +10 -0
  62. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  63. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +14 -1
  64. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  65. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +36 -0
  66. package/lib/esm/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +4 -7
  67. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  68. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  69. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  70. package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +2 -2
  71. package/lib/esm/view/transactionDetail/transactionDetailLocalDataHelper.js +14 -16
  72. package/lib/index.d.ts +16 -15
  73. package/lib/index.js +45 -42
  74. package/lib/reducer.d.ts +3 -0
  75. package/lib/reducer.js +3 -0
  76. package/lib/view/aiCfoView/aiCfoViewPayload.d.ts +0 -7
  77. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +1 -15
  78. package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -83
  79. package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -4
  80. package/lib/view/aiCfoView/aiCfoViewSelector.js +2 -9
  81. package/lib/view/aiCfoView/aiCfoViewState.d.ts +1 -18
  82. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  83. package/lib/view/classList/fetchClassListEpic.d.ts +1 -1
  84. package/lib/view/classList/fetchClassListEpic.js +1 -8
  85. package/lib/view/commonVendorView/vendorView/vendorViewSelector.d.ts +0 -1
  86. package/lib/view/commonVendorView/vendorView/vendorViewSelector.js +5 -15
  87. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.d.ts +0 -1
  88. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.js +2 -6
  89. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  90. package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +2 -2
  91. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  92. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
  93. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -18
  94. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
  95. package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  96. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +6 -61
  97. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +4 -12
  98. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  99. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +5 -11
  100. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -5
  101. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -19
  102. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  103. package/lib/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  104. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  105. package/lib/view/spendManagement/billPay/billList/billListState.js +0 -1
  106. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +3 -7
  107. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +5 -5
  108. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPayApproversDetailsEpic.js +2 -7
  109. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +6 -13
  110. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.d.ts +7 -0
  111. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +62 -0
  112. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.d.ts +34 -0
  113. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +2 -0
  114. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.d.ts +7 -0
  115. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +107 -0
  116. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.d.ts +16 -0
  117. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +67 -0
  118. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.d.ts +63 -0
  119. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +8 -0
  120. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.d.ts +20 -0
  121. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +66 -0
  122. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.d.ts +8 -0
  123. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +8 -0
  124. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.d.ts +13 -0
  125. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +8 -0
  126. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.d.ts +13 -0
  127. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +14 -0
  128. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  129. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  130. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +4 -1
  131. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +15 -2
  132. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  133. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.d.ts +12 -0
  134. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +40 -0
  135. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +3 -6
  136. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.d.ts +0 -1
  137. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  138. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  139. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  140. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  141. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +2 -2
  142. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +14 -16
  143. package/package.json +1 -1
  144. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -29
  145. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +0 -8
  146. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -33
@@ -1,6 +1,4 @@
1
1
  import omit from 'lodash/omit';
2
- import orderBy from 'lodash/orderBy';
3
- import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
4
2
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
5
3
  import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
6
4
  import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
@@ -12,46 +10,10 @@ import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDet
12
10
  import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
13
11
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
14
12
  import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
15
- function getJEScheduleSortAccessor(sortKey) {
16
- switch (sortKey) {
17
- case 'vendor':
18
- return (s) => s.vendor.name?.toLowerCase();
19
- case 'category':
20
- return (s) => s.jeDebit.account?.accountName?.toLowerCase();
21
- case 'class':
22
- return (s) => s.jeDebit.accountingClass?.className?.toLowerCase();
23
- case 'scheduleCategory':
24
- return (s) => s.jeScheduleType;
25
- case 'startMonth':
26
- return (s) => s.startDate?.valueOf();
27
- case 'type':
28
- return (s) => s.baseTransaction.typeOfTransaction;
29
- case 'amortizationPeriod':
30
- return (s) => s.period;
31
- case 'jePostingDate':
32
- return (s) => s.dayOfPostingDate;
33
- case 'remainingMonths':
34
- return (s) => s.period;
35
- case 'runningBalance':
36
- return (s) => s.balanceAsOfToday?.amount;
37
- case 'totalAmount':
38
- return (s) => s.baseTransaction.amount.amount;
39
- case 'transactionDate':
40
- return (s) => s.baseTransaction.date.valueOf();
41
- case 'memo':
42
- return (s) => s.baseTransaction.memo?.toLowerCase();
43
- default:
44
- return (s) => s.startDate?.valueOf();
45
- }
46
- }
47
- function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
48
- const accessor = getJEScheduleSortAccessor(sortKey);
49
- return orderBy(transactions, [accessor], [sortOrder === 'ascending' ? 'asc' : 'desc']);
50
- }
51
13
  export function getExpenseAutomationJESchedulesView(state) {
52
14
  const jeScheduledTransaction = [];
53
15
  const failedJeScheduledTransaction = [];
54
- const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
16
+ const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, } = state;
55
17
  const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
56
18
  const accountSettingsView = getJEAccountSettingsView(state);
57
19
  const currentTenant = getCurrentTenant(state);
@@ -97,33 +59,18 @@ export function getExpenseAutomationJESchedulesView(state) {
97
59
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
98
60
  failedJeScheduledTransaction.push(jeScheduleDetails);
99
61
  });
100
- const { sortKey, sortOrder } = uiState;
101
- const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
102
- const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
103
- const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
104
- schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
105
- const unsortedResolveSchedules = [];
62
+ const draftSchedules = jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft');
63
+ const resolveSchedules = [];
106
64
  failedJeScheduledTransaction.forEach((schedule) => {
107
65
  schedule.scheduledJournalEntry.forEach((journalEntry) => {
108
- unsortedResolveSchedules.push({
109
- ...schedule,
110
- scheduledJournalEntry: journalEntry,
111
- });
66
+ resolveSchedules.push({ ...schedule, scheduledJournalEntry: journalEntry });
112
67
  });
113
68
  });
114
- const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
115
69
  const allSteps = monthYearPeriodId != null
116
70
  ? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
117
71
  : [];
118
72
  const jeCompletionStatus = allSteps.find((step) => step.step === 'je_schedules')?.completionStatus;
119
73
  const completionStatus = jeCompletionStatus != null ? jeCompletionStatus : 'incomplete';
120
- const monthEndFetchState = monthYearPeriodId != null
121
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
122
- : { fetchState: 'Not-Started', error: undefined };
123
- const reducedFetchStatus = reduceAnyFetchState([
124
- { fetchState, error },
125
- monthEndFetchState,
126
- ]);
127
74
  return {
128
75
  uncategorizedAccounts,
129
76
  allDepreciationAccountList: filteredDepAccounts,
@@ -132,17 +79,15 @@ export function getExpenseAutomationJESchedulesView(state) {
132
79
  allAccountList: filteredAccounts,
133
80
  accountListNestedAccountHierarchy,
134
81
  allClassList: allClasses,
135
- completedSchedules,
136
82
  draftSchedules,
137
- ongoingSchedules,
138
83
  resolveSchedules: resolveSchedules,
139
84
  accountSettingsView,
140
85
  postStatusById: postStatusById,
141
86
  ignoreStatusById: ignoreStatusById,
142
- fetchState: reducedFetchStatus.fetchState,
87
+ fetchState: fetchState,
143
88
  jeScheduleLocalDataById: jeScheduleLocalDataById,
144
89
  uiState: uiState,
145
- error: reducedFetchStatus.error,
90
+ error: error,
146
91
  refreshStatus,
147
92
  completionStatus,
148
93
  };
@@ -1,5 +1,4 @@
1
1
  import orderBy from 'lodash/orderBy';
2
- import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
3
2
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
3
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
5
4
  import { getSupportedTransactionById, getSupportedTransactionsByIds, } from '../../../entity/transaction/transactionSelector';
@@ -8,7 +7,7 @@ import { getCompletedTransactionsCacheKey } from '../reducers/missingReceiptsVie
8
7
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
9
8
  import { isUnmatchedTabFileStatus, } from '../types/missingReceiptsViewState';
10
9
  export function getExpenseAutomationMissingReceiptsView(state) {
11
- const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
10
+ const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
12
11
  const currentTenant = getCurrentTenant(state);
13
12
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
14
13
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
@@ -37,7 +36,7 @@ export function getExpenseAutomationMissingReceiptsView(state) {
37
36
  transaction.lines.length > 0 &&
38
37
  transaction.lines[0]
39
38
  ?.class != null
40
- ? transaction.lines[0].class?.className.toLowerCase()
39
+ ? transaction.lines[0].class.className.toLowerCase()
41
40
  : null;
42
41
  case 'vendor':
43
42
  default:
@@ -176,16 +175,9 @@ export function getExpenseAutomationMissingReceiptsView(state) {
176
175
  vendorLogo: result.vendorLogo ?? transaction?.logo?.href,
177
176
  };
178
177
  });
179
- const monthEndFetchState = monthYearPeriodId != null
180
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
181
- : { fetchState: 'Not-Started', error: undefined };
182
- const reducedFetchStatus = reduceAnyFetchState([
183
- { fetchState, error },
184
- monthEndFetchState,
185
- ]);
186
178
  return {
187
- fetchState: reducedFetchStatus.fetchState,
188
- error: reducedFetchStatus.error,
179
+ fetchState,
180
+ error,
189
181
  uploadReceiptStatusById,
190
182
  uiState,
191
183
  refreshStatus,
@@ -13,7 +13,7 @@ import { getAccountList, getNestedAccountListHierarchy, } from '../../accountLis
13
13
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
14
14
  import { initialActionFetchState, initialReconciliationTabsState, initialState, } from '../reducers/reconciliationViewReducer';
15
15
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
16
- export const getExpenseAutomationReconciliationView = createSelector((state) => state, (state) => getCurrentTenant(state), (state) => state.expenseAutomationReconciliationViewState, (state) => state.expenseAutomationViewState, (state) => state.plaidAccountViewState, (state) => state.accountListState, (state) => state.accountState, (state) => state.classListState, (state) => state.classState, (state) => state.monthEndCloseChecksState, (state) => state.vendorState, (state) => state.monthEndCloseChecksViewState, (state, currentTenant, reconciliationViewState, expenseAutomationViewState, plaidAccountViewState, accountListState, accountState, classListState, classState, monthEndCloseChecksState, vendorState, monthEndCloseChecksViewState) => {
16
+ export const getExpenseAutomationReconciliationView = createSelector((state) => state, (state) => getCurrentTenant(state), (state) => state.expenseAutomationReconciliationViewState, (state) => state.expenseAutomationViewState, (state) => state.plaidAccountViewState, (state) => state.accountListState, (state) => state.accountState, (state) => state.classListState, (state) => state.classState, (state) => state.monthEndCloseChecksState, (state) => state.vendorState, (state, currentTenant, reconciliationViewState, expenseAutomationViewState, plaidAccountViewState, accountListState, accountState, classListState, classState, monthEndCloseChecksState, vendorState) => {
17
17
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
18
18
  const reconcileTabUiState = reconciliationViewState.reconTabsState.reconcile.uiState;
19
19
  const reviewTabUiState = reconciliationViewState.reconTabsState.review.uiState;
@@ -35,13 +35,6 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
35
35
  }
36
36
  return acc;
37
37
  }, []);
38
- const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
39
- const monthEndFetchState = monthYearPeriodId != null
40
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? {
41
- fetchState: 'Not-Started',
42
- error: undefined,
43
- })
44
- : { fetchState: 'Not-Started', error: undefined };
45
38
  if (accountReconForMonthYearPeriod == null) {
46
39
  return {
47
40
  bankAccounts: [],
@@ -51,13 +44,10 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
51
44
  classListNestedAccountHierarchy: [],
52
45
  allAccountList: [],
53
46
  allClassList: [],
54
- fetchStatus: reduceAnyFetchState([
55
- {
56
- fetchState: reconciliationViewState.fetchState,
57
- error: reconciliationViewState.error,
58
- },
59
- monthEndFetchState,
60
- ]),
47
+ fetchStatus: {
48
+ fetchState: reconciliationViewState.fetchState,
49
+ error: reconciliationViewState.error,
50
+ },
61
51
  plaidConnectionDetails: plaidAccountViewState['expense_automation_reconcile']
62
52
  .plaidConnectionDetails,
63
53
  completionStatus: 'incomplete',
@@ -280,13 +270,10 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
280
270
  bankAccounts: uniqueBankAccounts,
281
271
  creditCards: uniqueCreditCards,
282
272
  accountReconciliationsByAccountID: reconList,
283
- fetchStatus: reduceAnyFetchState([
284
- {
285
- fetchState: reconciliationViewState.fetchState,
286
- error: reconciliationViewState.error,
287
- },
288
- monthEndFetchState,
289
- ]),
273
+ fetchStatus: {
274
+ fetchState: reconciliationViewState.fetchState,
275
+ error: reconciliationViewState.error,
276
+ },
290
277
  plaidConnectionDetails: plaidAccountViewState['expense_automation_reconcile']
291
278
  .plaidConnectionDetails,
292
279
  reconciliationTabsState: reconciliationViewState.reconTabsState,
@@ -1,5 +1,5 @@
1
1
  import omit from 'lodash/omit';
2
- import { reduceAllFetchState, reduceAnyFetchState, } from '../../../commonStateTypes/reduceFetchState';
2
+ import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
3
3
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
4
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
5
5
  import { getTransactionWithCOT } from '../../../entity/transaction/transactionHelper';
@@ -8,7 +8,7 @@ import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts
8
8
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
9
9
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
10
10
  export function getExpenseAutomationTransactionView(state) {
11
- const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
11
+ const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
12
12
  const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
13
13
  const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
14
14
  const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
@@ -41,16 +41,10 @@ export function getExpenseAutomationTransactionView(state) {
41
41
  .filter((transaction) => transaction != null);
42
42
  const transactions = getSupportedTransactionsByIds(transactionState, transactionIds);
43
43
  const transactionsWithCOT = transactions.map((transaction) => getTransactionWithCOT(transaction));
44
- const monthEndFetchState = monthYearPeriodId != null
45
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
46
- : { fetchState: 'Not-Started', error: undefined };
47
- const fetchStatus = reduceAnyFetchState([
48
- reduceAllFetchState([
49
- accountList,
50
- classList,
51
- expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab],
52
- ]),
53
- monthEndFetchState,
44
+ const fetchStatus = reduceAllFetchState([
45
+ accountList,
46
+ classList,
47
+ expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab],
54
48
  ]);
55
49
  const totalCountByReview = expenseAutomationTransactionsViewState.transactionCategorizationView.review
56
50
  .uiState.totalCount;
@@ -1,17 +1 @@
1
- import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
2
- const JE_SCHEDULE_SORT_KEYS = [
3
- 'vendor',
4
- 'category',
5
- 'class',
6
- 'scheduleCategory',
7
- 'startMonth',
8
- 'type',
9
- 'amortizationPeriod',
10
- 'jePostingDate',
11
- 'remainingMonths',
12
- 'runningBalance',
13
- 'totalAmount',
14
- 'transactionDate',
15
- 'memo',
16
- ];
17
- export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
1
+ export {};
@@ -416,14 +416,6 @@ export const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions)
416
416
  transactionsWithNoSortKeyValue.push(transaction);
417
417
  }
418
418
  break;
419
- case 'invoiceNumber':
420
- if (transaction.documentId != null) {
421
- transactionsWithSortKeyValue.push(transaction);
422
- }
423
- else {
424
- transactionsWithNoSortKeyValue.push(transaction);
425
- }
426
- break;
427
419
  case 'dueDate':
428
420
  if (currentTab === 'draft') {
429
421
  if (Boolean(transaction.dueDate) === true) {
@@ -526,8 +518,6 @@ export const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions)
526
518
  return transaction.totalAmountInUSD?.amount ?? 0;
527
519
  case 'paymentMethod':
528
520
  return transaction.billPayInfo.billPaymentMethodType.name;
529
- case 'invoiceNumber':
530
- return transaction.documentId;
531
521
  }
532
522
  }, getColumnWiseSortOrder(sortOrder));
533
523
  return [
@@ -43,7 +43,6 @@ const ALL_BILL_PAY_SORT_KEYS = [
43
43
  'invoiceDate',
44
44
  'name',
45
45
  'paymentMethod',
46
- 'invoiceNumber',
47
46
  ];
48
47
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
48
  const toBillPaySortKeyType = (v) => stringToUnion(v, ALL_BILL_PAY_SORT_KEYS);
@@ -3,7 +3,6 @@ import { reduceFetchState } from '../../../../commonStateTypes/reduceFetchState'
3
3
  import { getContactsByIds } from '../../../../entity/billPay/contact/contactSelector';
4
4
  import { getPaymentAccountsByPaymentAccountIds } from '../../../../entity/paymentAccount/paymentAccountSelector';
5
5
  import { getVendorByVendorId } from '../../../../entity/vendor/vendorSelector';
6
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
7
6
  import { getAccountList } from '../../../accountList/accountListSelector';
8
7
  import { getAllFundingAccounts, } from '../../commonSetup/setupViewSelector';
9
8
  import { getAllDepositAccounts } from '../../zeniAccounts/depositAccountList/depositAccountListSelector';
@@ -74,14 +73,11 @@ export const getReviewPageBillDetail = (state, billId) => {
74
73
  }
75
74
  }
76
75
  if (sourceBillDetail != null) {
77
- const fetchStateList = [
76
+ sourceBillDetailFetchState = reduceFetchState([
78
77
  sourceBillDetail.fetchStatus,
79
78
  accountListState.byReportId['billPayAccountList'],
80
- ];
81
- if (getIsAccountingClassesEnabled(state)) {
82
- fetchStateList.push(classListState);
83
- }
84
- sourceBillDetailFetchState = reduceFetchState(fetchStateList).fetchState;
79
+ classListState,
80
+ ]).fetchState;
85
81
  }
86
82
  }
87
83
  else {
@@ -3,7 +3,6 @@ import cloneDeep from 'lodash/cloneDeep';
3
3
  import { reduceAllFetchState, reduceAnyFetchState, } from '../../../../commonStateTypes/reduceFetchState';
4
4
  import { getApprovalRulesByIds } from '../../../../entity/approvalRule/approvalRuleSelector';
5
5
  import { getClassesByIds } from '../../../../entity/class/classSelector';
6
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
7
6
  import { getUserByUserId } from '../../../../entity/user/userSelector';
8
7
  import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
9
8
  export const getBillPaySetupApproverView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (billPaySetupApproverViewState, approvalRuleState, userState) => {
@@ -45,7 +44,7 @@ export const getBillPaySetupApproverView = createSelector((state) => state.billP
45
44
  newApprovalRuleId,
46
45
  };
47
46
  });
48
- export const getBillPaySetupApproverUpdateDataView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (state) => state.classState, (state) => state.classListState, (state) => state.userRoleState, (state) => getIsAccountingClassesEnabled(state), (billPaySetupApproverViewState, approvalRuleState, userState, classState, classListState, userRoleState, isAccountingClassesEnabled) => {
47
+ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (state) => state.classState, (state) => state.classListState, (state) => state.userRoleState, (billPaySetupApproverViewState, approvalRuleState, userState, classState, classListState, userRoleState) => {
49
48
  const { affectedEntityIds, approvalRuleIds, approverListState, billPaySetupApproverViewUpdateData, fetchState, error, listeningToPusherEvent, } = billPaySetupApproverViewState;
50
49
  const { approverIds, attributes } = approverListState;
51
50
  const allApprovalRules = getApprovalRulesByIds(approvalRuleState, approvalRuleIds);
@@ -93,9 +92,10 @@ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => s
93
92
  allAttributes,
94
93
  filteredAttributes,
95
94
  billPaySetupApproverViewUpdateData,
96
- approverListFetchStatus: isAccountingClassesEnabled
97
- ? reduceAllFetchState([approverListState.fetchStatus, classListState])
98
- : approverListState.fetchStatus,
95
+ approverListFetchStatus: reduceAllFetchState([
96
+ approverListState.fetchStatus,
97
+ classListState,
98
+ ]),
99
99
  fetchState,
100
100
  allAccountingClasses,
101
101
  error,
@@ -1,27 +1,22 @@
1
1
  import { concat, from } from 'rxjs';
2
2
  import { filter, mergeMap } from 'rxjs/operators';
3
- import { getIsAccountingClassesEnabled } from '../../../../../entity/tenant/tenantSelector';
4
3
  import { fetchClassList } from '../../../../classList/classListReducer';
5
4
  import { fetchBillPayApproversDetails, fetchBillPayApproversList, } from '../billPaySetupApproverViewReducer';
6
5
  export const fetchBillPayApproversDetailsEpic = (actions$, state$) => actions$.pipe(filter(fetchBillPayApproversDetails.match), mergeMap((action) => {
7
6
  const { cacheOverride, includeUserRoles } = action.payload;
8
7
  const { billPaySetupApproverViewState, classListState } = state$.value;
9
8
  const { approverListState } = billPaySetupApproverViewState;
10
- const isAccountingClassesEnabled = getIsAccountingClassesEnabled(state$.value);
11
9
  const actions = [];
12
10
  if (cacheOverride === true) {
13
11
  actions.push(fetchBillPayApproversList(cacheOverride, includeUserRoles));
14
- if (isAccountingClassesEnabled) {
15
- actions.push(fetchClassList());
16
- }
12
+ actions.push(fetchClassList());
17
13
  }
18
14
  else {
19
15
  if (billPaySetupApproverViewState.hasValidState() === false &&
20
16
  approverListState.fetchStatus.fetchState !== 'In-Progress') {
21
17
  actions.push(fetchBillPayApproversList(true, includeUserRoles));
22
18
  }
23
- if (isAccountingClassesEnabled &&
24
- classListState.hasValidState() === false &&
19
+ if (classListState.hasValidState() === false &&
25
20
  classListState.fetchState !== 'In-Progress') {
26
21
  actions.push(fetchClassList());
27
22
  }
@@ -24,7 +24,6 @@ import { getAccountTypeSubConfigCodeKey, getBillPaymentSubConfigCodeKey, getBill
24
24
  import { getBillPayConfigByKey, getBillPayConfigByKeys, getInternationalMethodCode, } from '../billPayConfig/billPayConfigSelector';
25
25
  import { ACCOUNT_TYPE_CODES, BILL_PAYMENT_METHOD_CODE, BILL_PAYMENT_OUTSIDE_ZENI_SUB_CODES, BILL_PAYMENT_WIRE_SUB_CODES, INTERNATIONAL_CODES, INTERNATIONAL_SUB_CODES, PAYMENT_ACH_SUB_CODES, getBillPayConfigMethodKey, toBillPaymentSubConfigCodeKeyType, } from '../billPayConfig/billPayConfigState';
26
26
  import { getDuplicateBills, } from '../billPayReview/billPayReviewSelector';
27
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
28
27
  import { getBillPaySetupApproverView } from '../billPaySetupApproverView/billPaySetupApproverViewSelector';
29
28
  import { getPreviousBills, } from '../previousBills/previousBillsSelector';
30
29
  export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAccountsEnabled, billId) => {
@@ -173,15 +172,12 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
173
172
  isCancelled = sourceBillDetail.billDetailLocalData.isCancelled;
174
173
  billStage = billPayInfo?.stage.code ?? 'draft';
175
174
  if (billViewState != null) {
176
- const fetchStateList = [
175
+ fetchState = reduceFetchState([
177
176
  sourceBillDetail.fetchStatus,
178
177
  accountListState.byReportId.billPayAccountList,
178
+ classListState,
179
179
  billPaySetupApproverViewState,
180
- ];
181
- if (getIsAccountingClassesEnabled(state)) {
182
- fetchStateList.push(classListState);
183
- }
184
- fetchState = reduceFetchState(fetchStateList).fetchState;
180
+ ]).fetchState;
185
181
  deleteStatus = billViewState.deleteStatus;
186
182
  billActivities = getBillActivities(state, billId, billPayInfo?.stage.code);
187
183
  }
@@ -195,14 +191,11 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
195
191
  }
196
192
  }
197
193
  else {
198
- const newBillFetchStateList = [
194
+ fetchState = reduceFetchState([
199
195
  accountListState.byReportId.billPayAccountList,
196
+ classListState,
200
197
  billPaySetupApproverViewState,
201
- ];
202
- if (getIsAccountingClassesEnabled(state)) {
203
- newBillFetchStateList.push(classListState);
204
- }
205
- fetchState = reduceFetchState(newBillFetchStateList).fetchState;
198
+ ]).fetchState;
206
199
  }
207
200
  if (sourceBillDetail != null && fetchState == 'Completed') {
208
201
  const updatedRecord = sourceBillDetail.billDetailLocalData;
@@ -0,0 +1,58 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, mergeMap } from 'rxjs/operators';
3
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
4
+ import { updateAiCardRecommendation, updateAiCardRecommendationFailure, updateChainOfThoughts, updateChainOfThoughtsFailure, } from './cardsOnboardingReducer';
5
+ function isBareChainOfThoughtsPayload(value) {
6
+ if (value == null || typeof value !== 'object') {
7
+ return false;
8
+ }
9
+ const o = value;
10
+ return (typeof o.analyzing === 'string' &&
11
+ typeof o.thinking === 'string' &&
12
+ typeof o.thought_process === 'string');
13
+ }
14
+ function isBareAiCardRecommendationPayload(value) {
15
+ if (value == null || typeof value !== 'object') {
16
+ return false;
17
+ }
18
+ const o = value;
19
+ const pc = o.projected_coverage;
20
+ return (Array.isArray(o.vendor_cards) &&
21
+ Array.isArray(o.dept_cards) &&
22
+ typeof o.card_recommendation_pre_text === 'string' &&
23
+ (typeof pc === 'string' || typeof pc === 'number'));
24
+ }
25
+ export function requestChainOfThoughtsForAiCardRecommendation$(zeniAPI) {
26
+ const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/chain-of-thoughts-for-ai-card-recommendation`;
27
+ return zeniAPI.getJSON(url).pipe(mergeMap((response) => {
28
+ if (isSuccessResponse(response) && response.data != null) {
29
+ return of(updateChainOfThoughts(response.data));
30
+ }
31
+ if (isBareChainOfThoughtsPayload(response)) {
32
+ return of(updateChainOfThoughts(response));
33
+ }
34
+ if ('status' in response && response.status != null) {
35
+ return of(updateChainOfThoughtsFailure(response.status));
36
+ }
37
+ return of(updateChainOfThoughtsFailure(createZeniAPIStatus('Unexpected Error', 'Fetch chain of thoughts for AI card recommendation returned an invalid payload')));
38
+ }), catchError((error) => of(updateChainOfThoughtsFailure(createZeniAPIStatus('Unexpected Error', 'Fetch chain of thoughts for AI card recommendation REST API call errored out' +
39
+ JSON.stringify(error))))));
40
+ }
41
+ export function requestAiCardRecommendation$(zeniAPI) {
42
+ const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/ai-card-recommendation`;
43
+ return zeniAPI
44
+ .getJSON(url)
45
+ .pipe(mergeMap((response) => {
46
+ if (isSuccessResponse(response) && response.data != null) {
47
+ return of(updateAiCardRecommendation(response.data));
48
+ }
49
+ if (isBareAiCardRecommendationPayload(response)) {
50
+ return of(updateAiCardRecommendation(response));
51
+ }
52
+ if ('status' in response && response.status != null) {
53
+ return of(updateAiCardRecommendationFailure(response.status));
54
+ }
55
+ return of(updateAiCardRecommendationFailure(createZeniAPIStatus('Unexpected Error', 'Fetch AI card recommendation returned an invalid payload')));
56
+ }), catchError((error) => of(updateAiCardRecommendationFailure(createZeniAPIStatus('Unexpected Error', 'Fetch AI card recommendation REST API call errored out' +
57
+ JSON.stringify(error))))));
58
+ }
@@ -0,0 +1,103 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ const resetAiCardRecommendation = (draft) => {
3
+ draft.aiCardRecommendationFetchState = 'Not-Started';
4
+ draft.aiCardRecommendationResponse = undefined;
5
+ draft.aiCardRecommendationError = undefined;
6
+ };
7
+ const resetCreateAllAiRecommendedCards = (draft) => {
8
+ draft.createAllAiRecommendedCardsFetchState = 'Not-Started';
9
+ draft.createAllAiRecommendedCardsError = undefined;
10
+ };
11
+ export const initialState = {
12
+ aiCardRecommendationFetchState: 'Not-Started',
13
+ chainOfThoughtsFetchState: 'Not-Started',
14
+ chainOfThoughtsRevealPhase: 'none',
15
+ createAllAiRecommendedCardsFetchState: 'Not-Started',
16
+ aiCardRecommendationError: undefined,
17
+ aiCardRecommendationResponse: undefined,
18
+ chainOfThoughtsError: undefined,
19
+ chainOfThoughtsResponse: undefined,
20
+ createAllAiRecommendedCardsError: undefined,
21
+ };
22
+ const cardsOnboarding = createSlice({
23
+ name: 'cardsOnboarding',
24
+ initialState,
25
+ reducers: {
26
+ startAiCardAgentDrawerDataLoad(draft) {
27
+ draft.chainOfThoughtsFetchState = 'In-Progress';
28
+ draft.chainOfThoughtsError = undefined;
29
+ draft.chainOfThoughtsRevealPhase = 'none';
30
+ draft.chainOfThoughtsResponse = undefined;
31
+ draft.aiCardRecommendationFetchState = 'In-Progress';
32
+ draft.aiCardRecommendationError = undefined;
33
+ draft.aiCardRecommendationResponse = undefined;
34
+ resetCreateAllAiRecommendedCards(draft);
35
+ },
36
+ fetchChainOfThoughtsForAiCardRecommendation(draft) {
37
+ draft.chainOfThoughtsFetchState = 'In-Progress';
38
+ draft.chainOfThoughtsError = undefined;
39
+ draft.chainOfThoughtsRevealPhase = 'none';
40
+ resetAiCardRecommendation(draft);
41
+ resetCreateAllAiRecommendedCards(draft);
42
+ },
43
+ updateChainOfThoughts(draft, action) {
44
+ draft.chainOfThoughtsResponse = toChainOfThoughtsResponse(action.payload);
45
+ draft.chainOfThoughtsFetchState = 'Completed';
46
+ draft.chainOfThoughtsRevealPhase = 'analyzing';
47
+ },
48
+ updateChainOfThoughtsFailure(draft, action) {
49
+ draft.chainOfThoughtsFetchState = 'Error';
50
+ draft.chainOfThoughtsError = action.payload;
51
+ draft.chainOfThoughtsRevealPhase = 'none';
52
+ },
53
+ setChainOfThoughtsRevealPhase(draft, action) {
54
+ draft.chainOfThoughtsRevealPhase = action.payload;
55
+ },
56
+ fetchAiCardRecommendation(draft) {
57
+ draft.aiCardRecommendationFetchState = 'In-Progress';
58
+ draft.aiCardRecommendationError = undefined;
59
+ },
60
+ updateAiCardRecommendation(draft, action) {
61
+ draft.aiCardRecommendationResponse = toAiCardRecommendationResponse(action.payload);
62
+ draft.aiCardRecommendationFetchState = 'Completed';
63
+ },
64
+ updateAiCardRecommendationFailure(draft, action) {
65
+ draft.aiCardRecommendationFetchState = 'Error';
66
+ draft.aiCardRecommendationError = action.payload;
67
+ },
68
+ createAllAiRecommendedCards: {
69
+ reducer(draft, action) {
70
+ void action;
71
+ draft.createAllAiRecommendedCardsFetchState = 'In-Progress';
72
+ draft.createAllAiRecommendedCardsError = undefined;
73
+ },
74
+ prepare(cards) {
75
+ return { payload: cards };
76
+ },
77
+ },
78
+ createAllAiRecommendedCardsSucceeded(draft) {
79
+ draft.createAllAiRecommendedCardsFetchState = 'Completed';
80
+ draft.createAllAiRecommendedCardsError = undefined;
81
+ },
82
+ createAllAiRecommendedCardsFailed(draft, action) {
83
+ draft.createAllAiRecommendedCardsFetchState = 'Error';
84
+ draft.createAllAiRecommendedCardsError = action.payload;
85
+ },
86
+ clearCardsOnboarding(draft) {
87
+ Object.assign(draft, initialState);
88
+ },
89
+ },
90
+ });
91
+ export const { startAiCardAgentDrawerDataLoad, fetchChainOfThoughtsForAiCardRecommendation, updateChainOfThoughts, updateChainOfThoughtsFailure, setChainOfThoughtsRevealPhase, fetchAiCardRecommendation, updateAiCardRecommendation, updateAiCardRecommendationFailure, createAllAiRecommendedCards, createAllAiRecommendedCardsSucceeded, createAllAiRecommendedCardsFailed, clearCardsOnboarding, } = cardsOnboarding.actions;
92
+ export default cardsOnboarding.reducer;
93
+ const toChainOfThoughtsResponse = (payload) => ({
94
+ analyzing: payload.analyzing,
95
+ thinking: payload.thinking,
96
+ thought_process: payload.thought_process,
97
+ });
98
+ const toAiCardRecommendationResponse = (payload) => ({
99
+ vendor_cards: payload.vendor_cards,
100
+ dept_cards: payload.dept_cards,
101
+ card_recommendation_pre_text: payload.card_recommendation_pre_text,
102
+ projected_coverage: String(payload.projected_coverage),
103
+ });