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

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 (156) hide show
  1. package/lib/entity/account/accountPayload.d.ts +0 -2
  2. package/lib/entity/account/accountPayload.js +0 -2
  3. package/lib/entity/account/accountState.d.ts +0 -2
  4. package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
  5. package/lib/entity/depositAccount/depositAccount.js +1 -8
  6. package/lib/entity/reimbursement/reimbursementPayload.d.ts +0 -2
  7. package/lib/entity/reimbursement/reimbursementPayload.js +0 -7
  8. package/lib/entity/reimbursement/reimbursementState.d.ts +0 -2
  9. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  10. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  11. package/lib/entity/task/taskPayload.d.ts +0 -1
  12. package/lib/entity/task/taskPayload.js +0 -1
  13. package/lib/entity/task/taskState.d.ts +0 -1
  14. package/lib/epic.d.ts +1 -17
  15. package/lib/epic.js +1 -17
  16. package/lib/esm/entity/account/accountPayload.js +0 -2
  17. package/lib/esm/entity/depositAccount/depositAccount.js +1 -8
  18. package/lib/esm/entity/reimbursement/reimbursementPayload.js +0 -7
  19. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  20. package/lib/esm/entity/task/taskPayload.js +0 -1
  21. package/lib/esm/epic.js +1 -17
  22. package/lib/esm/index.js +5 -14
  23. package/lib/esm/reducer.js +0 -9
  24. package/lib/esm/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +3 -8
  25. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  26. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -189
  27. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -433
  28. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -23
  29. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -244
  30. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  31. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -44
  32. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  33. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +1 -14
  34. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  35. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  36. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +1 -3
  37. package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +0 -11
  38. package/lib/esm/zeniAPI.js +2 -0
  39. package/lib/index.d.ts +6 -14
  40. package/lib/index.js +32 -95
  41. package/lib/reducer.d.ts +0 -9
  42. package/lib/reducer.js +0 -9
  43. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +3 -8
  44. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  45. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  46. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -118
  47. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -201
  48. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -76
  49. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -434
  50. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -11
  51. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -24
  52. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -69
  53. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -1
  54. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  55. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -243
  56. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  57. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -142
  58. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -54
  59. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -2
  60. package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  61. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +1 -4
  62. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +2 -15
  63. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  64. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +0 -1
  65. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  66. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +0 -2
  67. package/lib/view/taskManager/taskListView/taskListSelector.js +1 -3
  68. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +1 -3
  69. package/lib/view/userListView/fetchUserListByTypeEpic.js +0 -11
  70. package/lib/view/userListView/userListViewPayload.d.ts +0 -2
  71. package/lib/zeniAPI.js +2 -0
  72. package/package.json +2 -2
  73. package/lib/entity/userGroups/userGroupsPayload.d.ts +0 -7
  74. package/lib/entity/userGroups/userGroupsPayload.js +0 -10
  75. package/lib/entity/userGroups/userGroupsReducer.d.ts +0 -8
  76. package/lib/entity/userGroups/userGroupsReducer.js +0 -29
  77. package/lib/entity/userGroups/userGroupsSelector.d.ts +0 -4
  78. package/lib/entity/userGroups/userGroupsSelector.js +0 -12
  79. package/lib/entity/userGroups/userGroupsState.d.ts +0 -9
  80. package/lib/entity/userGroups/userGroupsState.js +0 -2
  81. package/lib/esm/entity/userGroups/userGroupsPayload.js +0 -7
  82. package/lib/esm/entity/userGroups/userGroupsReducer.js +0 -25
  83. package/lib/esm/entity/userGroups/userGroupsSelector.js +0 -8
  84. package/lib/esm/entity/userGroups/userGroupsState.js +0 -1
  85. package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +0 -10
  86. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -29
  87. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
  88. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -40
  89. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -47
  90. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
  91. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -33
  92. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -56
  93. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -77
  94. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -79
  95. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -24
  96. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +0 -58
  97. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +0 -1
  98. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +0 -103
  99. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +0 -63
  100. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +0 -5
  101. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +0 -62
  102. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +0 -4
  103. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +0 -4
  104. package/lib/esm/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +0 -10
  105. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +0 -36
  106. package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +0 -65
  107. package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +0 -16
  108. package/lib/esm/view/userGroupListView/userGroupListViewState.js +0 -1
  109. package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +0 -10
  110. package/lib/view/expenseAutomationView/bulkUploadTiming.js +0 -13
  111. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -18
  112. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -33
  113. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
  114. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
  115. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
  116. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -44
  117. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
  118. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -51
  119. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
  120. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -65
  121. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
  122. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -37
  123. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -9
  124. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -61
  125. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -14
  126. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -81
  127. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -25
  128. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -85
  129. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +0 -7
  130. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -28
  131. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.d.ts +0 -7
  132. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingDataRequests.js +0 -62
  133. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.d.ts +0 -34
  134. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingPayload.js +0 -2
  135. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.d.ts +0 -7
  136. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingReducer.js +0 -107
  137. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.d.ts +0 -16
  138. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingSelector.js +0 -67
  139. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.d.ts +0 -63
  140. package/lib/view/spendManagement/chargeCards/cardsOnboarding/cardsOnboardingState.js +0 -8
  141. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.d.ts +0 -20
  142. package/lib/view/spendManagement/chargeCards/cardsOnboarding/createAllAiRecommendedCardsEpic.js +0 -66
  143. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.d.ts +0 -8
  144. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchAiCardRecommendationEpic.js +0 -8
  145. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.d.ts +0 -13
  146. package/lib/view/spendManagement/chargeCards/cardsOnboarding/fetchChainOfThoughtsForAiCardRecommendationEpic.js +0 -8
  147. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.d.ts +0 -13
  148. package/lib/view/spendManagement/chargeCards/cardsOnboarding/startAiCardAgentDrawerDataLoadEpic.js +0 -14
  149. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.d.ts +0 -12
  150. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchCardsOnboardingPageEpic.js +0 -40
  151. package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +0 -23
  152. package/lib/view/userGroupListView/userGroupListViewReducer.js +0 -69
  153. package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +0 -7
  154. package/lib/view/userGroupListView/userGroupListViewSelector.js +0 -20
  155. package/lib/view/userGroupListView/userGroupListViewState.d.ts +0 -8
  156. package/lib/view/userGroupListView/userGroupListViewState.js +0 -2
@@ -1,77 +0,0 @@
1
- import { EMPTY, from, merge, of } from 'rxjs';
2
- import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
3
- import { convertToPeriod } from '../../../../commonStateTypes/timePeriod';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
6
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
7
- import { supportedTransactionPayloadToManualSearchResult } from '../../payload/missingReceiptsPayload';
8
- import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
9
- import { toTransactionsSortKey } from '../../types/transactionsViewState';
10
- /**
11
- * `auto_categorized` for manual transaction search (Unmatched).
12
- * Backend contract TBD — align with `fetchTransactionCategorizationEpic` (`selectedTab === 'autoCategorized'`)
13
- * when the expense-automation API documents the intended filter for this flow.
14
- */
15
- export const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
16
- export const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
17
- const searchActions$ = actions$.pipe(filter(searchTransactionsForManualMatch.match));
18
- const pagination$ = searchActions$.pipe(filter((action) => action.payload.pageToken != null));
19
- /**
20
- * No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP.
21
- */
22
- const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null &&
23
- action.payload.query.trim().length < 2));
24
- const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null &&
25
- action.payload.query.trim().length >= 2), debounceTime(300));
26
- return merge(pagination$, newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
27
- const { query, pageToken } = action.payload;
28
- if (pageToken == null && query.trim().length < 2) {
29
- return EMPTY;
30
- }
31
- const state = state$.value;
32
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
33
- const currentTenant = getCurrentTenant(state);
34
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
35
- if (selectedPeriod == null) {
36
- return of(searchTransactionsForManualMatchFailure({
37
- error: createZeniAPIStatus('Unexpected Error', 'Manual search requires a selected accounting period.'),
38
- }));
39
- }
40
- const period = convertToPeriod(selectedPeriod);
41
- const queryParam = {
42
- start_date: period.start,
43
- end_date: period.end,
44
- auto_categorized: MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
45
- sort_by: toTransactionsSortKey(sortKey),
46
- sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
47
- page_token: pageToken ?? null,
48
- page_size: manualSearch.pageSize,
49
- search_text: query,
50
- };
51
- return zeniAPI
52
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
53
- .pipe(mergeMap((response) => {
54
- if (isSuccessResponse(response) && response.data != null) {
55
- const { transactions, next_page_token, total_count } = response.data;
56
- const append = pageToken != null;
57
- const results = transactions.map(supportedTransactionPayloadToManualSearchResult);
58
- const actionsOut = [
59
- updateTransactions(transactions, (value) => value.transaction_id, 'merge'),
60
- searchTransactionsForManualMatchSuccess({
61
- append,
62
- nextPageToken: next_page_token ?? null,
63
- results,
64
- totalCount: total_count,
65
- }),
66
- ];
67
- return from(actionsOut);
68
- }
69
- return of(searchTransactionsForManualMatchFailure({
70
- error: response.status,
71
- }));
72
- }), catchError((error) => of(searchTransactionsForManualMatchFailure({
73
- error: createZeniAPIStatus('Unexpected Error', 'Search transactions for manual match errored: ' +
74
- JSON.stringify(error)),
75
- }))));
76
- }));
77
- };
@@ -1,79 +0,0 @@
1
- import { EMPTY, from, merge, of, timer } from 'rxjs';
2
- import { catchError, debounceTime, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
5
- import { isSuccessResponse } from '../../../../responsePayload';
6
- import { BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS } from '../../bulkUploadTiming';
7
- import { extractTransactionPayloadsFromBatchFiles, isBatchDetailsApiStatusCompleted, toBatchDetails, } from '../../payload/missingReceiptsPayload';
8
- import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, } from '../../reducers/missingReceiptsViewReducer';
9
- /** First poll after upload; then interval while batch not resolved via Pusher or API. */
10
- const FALLBACK_FIRST_DELAY_MS = 30000;
11
- const FALLBACK_POLL_INTERVAL_MS = 10000;
12
- /**
13
- * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
14
- * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
15
- */
16
- export const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((action) => action.payload.status === 'completed'), debounceTime(300), mergeMap(() => from([
17
- fetchBulkUploadBatches({
18
- cacheOverride: true,
19
- invalidateBatchDetailsCache: true,
20
- }),
21
- requestMissingReceiptsTabNavigation({ tab: 'unmatched' }),
22
- ])));
23
- /**
24
- * If Pusher and batch-details are delayed beyond {@link BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS},
25
- * force `phase` to `completed` (dismiss automatching banner) and refresh the batch list.
26
- * Cancels when the batch completes normally, bulk state is cleared, or another upload supersedes.
27
- */
28
- export const bulkUploadAutomatchingTimeoutEpic = (actions$, state$) => actions$.pipe(filter(bulkUploadReceiptsSuccess.match), mergeMap((action) => {
29
- const { batchId } = action.payload;
30
- return timer(BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS).pipe(mergeMap(() => {
31
- const bulk = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
32
- if (bulk.phase !== 'matching' || bulk.currentBatchId !== batchId) {
33
- return EMPTY;
34
- }
35
- return from([
36
- bulkUploadAutomatchingTimedOut(batchId),
37
- fetchBulkUploadBatches({ cacheOverride: true }),
38
- ]);
39
- }), takeUntil(merge(actions$.pipe(filter(clearBulkUpload.match)), actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((a) => a.payload.batchId === batchId &&
40
- a.payload.status === 'completed')), actions$.pipe(filter(fetchBulkUploadBatchDetailsSuccess.match), filter((a) => a.payload.batchId === batchId)))));
41
- }));
42
- /**
43
- * Fallback polling when Pusher is slow or unavailable. Network errors on a poll tick show one
44
- * error snackbar per upload session (first failure only) so the user is not spammed every
45
- * interval; Pusher or a later successful poll still completes the flow.
46
- */
47
- export const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceiptsSuccess.match), mergeMap((action) => {
48
- const { batchId } = action.payload;
49
- let pollErrorNotified = false;
50
- return timer(FALLBACK_FIRST_DELAY_MS, FALLBACK_POLL_INTERVAL_MS).pipe(takeUntil(merge(actions$.pipe(filter(clearBulkUpload.match)), actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((action) => action.payload.batchId === batchId)), actions$.pipe(filter(fetchBulkUploadBatchDetailsSuccess.match), filter((action) => action.payload.batchId === batchId)), actions$.pipe(filter(bulkUploadAutomatchingTimedOut.match), filter((action) => action.payload.batchId === batchId)))), switchMap(() => zeniAPI
51
- .getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${batchId}`)
52
- .pipe(mergeMap((response) => {
53
- /** Same batch-details URL; polls until `status` is completed (Pusher may win first). */
54
- if (isSuccessResponse(response) && response.data != null) {
55
- if (isBatchDetailsApiStatusCompleted(response.data.status)) {
56
- const actions = [];
57
- const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
58
- if (transactionPayloads.length > 0) {
59
- actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
60
- }
61
- actions.push(fetchBulkUploadBatchDetailsSuccess(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
62
- actions.push(fetchBulkUploadBatches({ cacheOverride: true }));
63
- actions.push(requestMissingReceiptsTabNavigation({ tab: 'unmatched' }));
64
- return from(actions);
65
- }
66
- }
67
- return EMPTY;
68
- }), catchError(() => {
69
- if (!pollErrorNotified) {
70
- pollErrorNotified = true;
71
- return of(openSnackbar({
72
- messageSection: 'receipts_upload',
73
- messageText: 'failed',
74
- type: 'error',
75
- }));
76
- }
77
- return EMPTY;
78
- }))));
79
- }));
@@ -1,24 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { filter, mergeMap } from 'rxjs/operators';
3
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
4
- import { updateTransaction } from '../../../../entity/transaction/transactionReducer';
5
- import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
6
- import { uploadTransactionCategorizationReceiptSuccess } from '../../reducers/transactionsViewReducer';
7
- export const uploadTransactionReceiptSuccessEpic = (actions$, state$) => actions$.pipe(filter(uploadTransactionCategorizationReceiptSuccess.match), mergeMap((action) => {
8
- const { transactionPayload, updateType } = action.payload;
9
- const updateActions = [];
10
- const currentTenant = getCurrentTenant(state$.value);
11
- const selectedPeriodByTenantId = state$.value.expenseAutomationViewState.selectedPeriodByTenantId;
12
- updateActions.push(updateTransaction(transactionPayload.transaction_id, transactionPayload, updateType));
13
- if (currentTenant != null) {
14
- const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
15
- if (monthEndChecksPeriod != null) {
16
- updateActions.push(fetchMonthEndCloseChecks({
17
- tenantId: currentTenant.tenantId,
18
- period: monthEndChecksPeriod,
19
- refreshViewInBackground: true,
20
- }));
21
- }
22
- }
23
- return from(updateActions);
24
- }));
@@ -1,58 +0,0 @@
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
- }
@@ -1,103 +0,0 @@
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
- });
@@ -1,63 +0,0 @@
1
- import { getUserByUserId, getUserName, } from '../../../../entity/user/userSelector';
2
- function collectOwnerIds(rec) {
3
- const ids = new Set();
4
- for (const c of rec.vendor_cards) {
5
- ids.add(c.owner_id);
6
- }
7
- for (const c of rec.dept_cards) {
8
- ids.add(c.owner_id);
9
- }
10
- return [...ids];
11
- }
12
- function enrichCard(card, userState) {
13
- const user = getUserByUserId(userState, card.owner_id);
14
- const hasOwnerDetails = user != null;
15
- return {
16
- ...card,
17
- hasOwnerDetails,
18
- ownerDisplayName: hasOwnerDetails
19
- ? getUserName(user) || card.owner_id
20
- : card.owner_id,
21
- ownerProfilePhoto: user?.photo,
22
- };
23
- }
24
- /**
25
- * Layout hints when using `startAiCardAgentDrawerDataLoad` (parallel CoT + recommendation GETs).
26
- * - Run phased CoT after `hasChainOfThoughtContent`; end with `setChainOfThoughtsRevealPhase('complete')`.
27
- * - Show sparkle when `showRecommendationSparkle` (AI still loading).
28
- * - Render tables / pre text / coverage only when `showRecommendationSection`.
29
- */
30
- export function getAiCardAgentDrawerDisplayState(state) {
31
- const c = state.cardsOnboardingState;
32
- const cotDone = c.chainOfThoughtsRevealPhase === 'complete';
33
- const aiDone = c.aiCardRecommendationFetchState === 'Completed' &&
34
- c.aiCardRecommendationResponse != null;
35
- return {
36
- showChainOfThoughtShimmer: c.chainOfThoughtsFetchState === 'In-Progress',
37
- hasChainOfThoughtContent: c.chainOfThoughtsFetchState === 'Completed' &&
38
- c.chainOfThoughtsResponse != null,
39
- showRecommendationSparkle: c.aiCardRecommendationFetchState === 'In-Progress',
40
- showRecommendationSection: cotDone && aiDone,
41
- };
42
- }
43
- /**
44
- * Enriches `aiCardRecommendationResponse` with owner display name and photo from `userState`.
45
- * `ownerIdsMissingFromStore` lists `owner_id`s not in `userState` after the **single** people load
46
- * (e.g. `fetchCardsOnboardingPageEpic` → `fetchPeople()`). Do not refetch people from this package;
47
- * show a fallback label or rely on the owner dropdown sourced from the same store.
48
- */
49
- export function getAiCardRecommendationDisplayView(state) {
50
- const rec = state.cardsOnboardingState.aiCardRecommendationResponse;
51
- if (rec == null) {
52
- return undefined;
53
- }
54
- const { userState } = state;
55
- const ownerIdsMissingFromStore = collectOwnerIds(rec).filter((id) => userState.userByUserId[id] == null);
56
- return {
57
- card_recommendation_pre_text: rec.card_recommendation_pre_text,
58
- projected_coverage: rec.projected_coverage,
59
- vendor_cards: rec.vendor_cards.map((c) => enrichCard(c, userState)),
60
- dept_cards: rec.dept_cards.map((c) => enrichCard(c, userState)),
61
- ownerIdsMissingFromStore,
62
- };
63
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * In-app path to open after a successful “Create All Cards” from AI recommendations
3
- * (e.g. `https://qa.app.zeni.ai` + this path). Routing is handled by the host app.
4
- */
5
- export const CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH = '/zeni.ai/cards';
@@ -1,62 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAddresses } from '../../../../entity/address/addressReducer';
4
- import { updateChargeCards } from '../../../../entity/chargeCard/chargeCardReducer';
5
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
6
- import { updateAllUsers } from '../../../../entity/user/userReducer';
7
- import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
8
- import { createZeniAPIStatus, isSuccessStatus, } from '../../../../responsePayload';
9
- import { updateChargeCardList } from '../chargeCardList/chargeCardListReducer';
10
- import { updateChargeCardCount, updateDebitCardCount, } from '../issueChargeCard/issueChargeCardReducer';
11
- import { createAllAiRecommendedCards, createAllAiRecommendedCardsFailed, createAllAiRecommendedCardsSucceeded, } from './cardsOnboardingReducer';
12
- function draftsToApiCards(drafts) {
13
- return drafts.map((d) => ({
14
- card_holder_user_ids: [d.owner_id],
15
- card_name: d.card_name,
16
- card_type: d.card_type ?? 'business_virtual_credit_card',
17
- currency_code: d.currency_code ?? 'USD',
18
- purchase_limit: d.purchase_limit,
19
- purchase_limit_frequency: d.purchase_limit_frequency ?? { code: 'monthly' },
20
- }));
21
- }
22
- /**
23
- * POST `${cardMicroServiceBaseUrl}/1.0/cards` with edited AI recommendation rows.
24
- * On success, merges issued cards into entity + list state (same pattern as issue charge card).
25
- * Host app: when `createAllAiRecommendedCardsFetchState === 'Completed'`, navigate to
26
- * `CREATE_ALL_AI_RECOMMENDED_CARDS_SUCCESS_APP_PATH`.
27
- */
28
- export const createAllAiRecommendedCardsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createAllAiRecommendedCards.match), switchMap((action) => {
29
- if (action.payload.length === 0) {
30
- return of(createAllAiRecommendedCardsFailed(createZeniAPIStatus('Validation', 'No cards to create')));
31
- }
32
- const cards = draftsToApiCards(action.payload);
33
- return zeniAPI
34
- .postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`, { cards })
35
- .pipe(mergeMap((response) => {
36
- if (isSuccessStatus(response) && response.data != null) {
37
- const actions = [
38
- updateChargeCards(response.data.cards),
39
- updateAllUsers({ users: response.data.users }),
40
- updateUserRoles(response.data.user_roles),
41
- updateChargeCardList({
42
- chargeCardListPayload: response.data,
43
- keepExistingListItems: true,
44
- }),
45
- updateAddresses(response.data.addresses),
46
- updateChargeCardCount(response.data?.cards_count_by_user_id ?? []),
47
- updateDebitCardCount(response.data?.debit_cards_count_by_deposit_account_id ?? {}),
48
- createAllAiRecommendedCardsSucceeded(),
49
- openSnackbar({
50
- messageSection: 'issue_charge_cards',
51
- messageText: 'success',
52
- type: 'success',
53
- }),
54
- ];
55
- return from(actions);
56
- }
57
- return of(createAllAiRecommendedCardsFailed(response.status));
58
- }), catchError((error) => {
59
- return of(createAllAiRecommendedCardsFailed(createZeniAPIStatus('Unexpected Error', 'Create all AI recommended cards REST API call errored out' +
60
- JSON.stringify(error))));
61
- }));
62
- }));
@@ -1,4 +0,0 @@
1
- import { filter, switchMap } from 'rxjs/operators';
2
- import { requestAiCardRecommendation$, } from './cardsOnboardingDataRequests';
3
- import { fetchAiCardRecommendation } from './cardsOnboardingReducer';
4
- export const fetchAiCardRecommendationEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchAiCardRecommendation.match), switchMap(() => requestAiCardRecommendation$(zeniAPI)));
@@ -1,4 +0,0 @@
1
- import { filter, switchMap } from 'rxjs/operators';
2
- import { requestChainOfThoughtsForAiCardRecommendation$, } from './cardsOnboardingDataRequests';
3
- import { fetchChainOfThoughtsForAiCardRecommendation } from './cardsOnboardingReducer';
4
- export const fetchChainOfThoughtsForAiCardRecommendationEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchChainOfThoughtsForAiCardRecommendation.match), switchMap(() => requestChainOfThoughtsForAiCardRecommendation$(zeniAPI)));
@@ -1,10 +0,0 @@
1
- import { merge } from 'rxjs';
2
- import { filter, switchMap } from 'rxjs/operators';
3
- import { requestAiCardRecommendation$, requestChainOfThoughtsForAiCardRecommendation$, } from './cardsOnboardingDataRequests';
4
- import { startAiCardAgentDrawerDataLoad } from './cardsOnboardingReducer';
5
- /**
6
- * On "Let's get started": runs chain-of-thoughts GET and AI card recommendation GET **in parallel**.
7
- * Reducer (`startAiCardAgentDrawerDataLoad`) resets both slices; use `getAiCardAgentDrawerDisplayState`
8
- * for phased CoT UI, sparkle while recommendations load, and gated recommendation content.
9
- */
10
- export const startAiCardAgentDrawerDataLoadEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(startAiCardAgentDrawerDataLoad.match), switchMap(() => merge(requestChainOfThoughtsForAiCardRecommendation$(zeniAPI), requestAiCardRecommendation$(zeniAPI))));
@@ -1,36 +0,0 @@
1
- import { concat, from } from 'rxjs';
2
- import { filter, mergeMap } from 'rxjs/operators';
3
- import { fetchPeople } from '../../../people/peopleReducer';
4
- import { fetchCashbackDetail } from '../cashbackDetail/cashbackDetailReducer';
5
- import { fetchCardsOnboardingPage, fetchCreditAccount, } from './chargeCardListReducer';
6
- export const fetchCardsOnboardingPageEpic = (actions$, state$) => actions$.pipe(filter(fetchCardsOnboardingPage.match), mergeMap((action) => {
7
- const { isCreditCardEnabled, cacheOverride } = action.payload;
8
- const actions = [];
9
- const state = state$.value;
10
- if (cacheOverride === true) {
11
- if (isCreditCardEnabled) {
12
- actions.push(fetchCreditAccount());
13
- }
14
- actions.push(fetchCashbackDetail());
15
- actions.push(fetchPeople());
16
- }
17
- else {
18
- const chargeCardList = state.chargeCardListState;
19
- if (isCreditCardEnabled &&
20
- chargeCardList.creditAccount.fetchState !== 'Completed' &&
21
- chargeCardList.creditAccount.fetchState !== 'In-Progress') {
22
- actions.push(fetchCreditAccount());
23
- }
24
- const cashbackDetailState = state.cashbackDetailState;
25
- if (cashbackDetailState.fetchState !== 'In-Progress' &&
26
- cashbackDetailState.hasValidState() === false) {
27
- actions.push(fetchCashbackDetail());
28
- }
29
- const peopleState = state.peopleState;
30
- if (peopleState.fetchState !== 'In-Progress' &&
31
- peopleState.hasValidState() === false) {
32
- actions.push(fetchPeople());
33
- }
34
- }
35
- return concat(from(actions));
36
- }));
@@ -1,65 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- const initialUserGroupList = {
3
- ids: [],
4
- fetchState: 'Not-Started',
5
- error: undefined,
6
- hasValidState() {
7
- return this.fetchState == 'Completed';
8
- },
9
- };
10
- export const initialState = {
11
- userGroupListByType: {
12
- taskManagerCandidate: initialUserGroupList,
13
- },
14
- };
15
- const userGroupListView = createSlice({
16
- name: 'userGroupListView',
17
- initialState,
18
- reducers: {
19
- fetchUserGroupListByType: {
20
- reducer(draft, action) {
21
- const { userGroupType } = action.payload;
22
- draft.userGroupListByType[userGroupType].fetchState = 'In-Progress';
23
- draft.userGroupListByType[userGroupType].error = undefined;
24
- },
25
- prepare(userGroupType, cacheOverride = false) {
26
- return {
27
- payload: {
28
- userGroupType,
29
- cacheOverride,
30
- },
31
- };
32
- },
33
- },
34
- updateUserGroupIds(draft, action) {
35
- const { userGroupType, userGroupsPayload } = action.payload;
36
- draft.userGroupListByType[userGroupType].fetchState = 'Completed';
37
- draft.userGroupListByType[userGroupType].error = undefined;
38
- draft.userGroupListByType[userGroupType].ids = userGroupsPayload.map((userGroup) => userGroup.id);
39
- },
40
- addUserGroupId(draft, action) {
41
- const { userGroupType, id } = action.payload;
42
- const index = draft.userGroupListByType[userGroupType].ids.indexOf(id);
43
- if (index < 0) {
44
- draft.userGroupListByType[userGroupType].ids.push(id);
45
- }
46
- },
47
- removeUserGroupId(draft, action) {
48
- const { userGroupType, id } = action.payload;
49
- const index = draft.userGroupListByType[userGroupType].ids.indexOf(id);
50
- if (index > -1) {
51
- draft.userGroupListByType[userGroupType].ids.splice(index, 1);
52
- }
53
- },
54
- updateUserGroupListFetchFailure(draft, action) {
55
- const { userGroupType, status } = action.payload;
56
- draft.userGroupListByType[userGroupType].fetchState = 'Error';
57
- draft.userGroupListByType[userGroupType].error = status;
58
- },
59
- clearUserGroupListView(draft) {
60
- Object.assign(draft, initialState);
61
- },
62
- },
63
- });
64
- export const { fetchUserGroupListByType, updateUserGroupIds, addUserGroupId, removeUserGroupId, updateUserGroupListFetchFailure, clearUserGroupListView, } = userGroupListView.actions;
65
- export default userGroupListView.reducer;
@@ -1,16 +0,0 @@
1
- import { getUserGroupByUserGroupId } from '../../entity/userGroups/userGroupsSelector';
2
- export const getUserGroupList = (userGroupsState, userGroupListViewState, userGroupType) => {
3
- const listState = userGroupListViewState.userGroupListByType[userGroupType];
4
- return {
5
- userGroups: getUserGroupListByIds(userGroupsState, userGroupListViewState, userGroupType),
6
- fetchState: listState?.fetchState,
7
- error: listState?.error,
8
- version: 0,
9
- };
10
- };
11
- function getUserGroupListByIds(userGroupsState, userGroupListViewState, type) {
12
- const userGroupIds = userGroupListViewState.userGroupListByType[type].ids;
13
- return userGroupIds
14
- .map((id) => getUserGroupByUserGroupId(userGroupsState, id))
15
- .filter((value) => value != null);
16
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * After upload API success, hold the bar at 100% this long before transitioning to matching,
3
- * so the fill animation can complete without an abrupt swap to the auto-matching banner.
4
- */
5
- export declare const BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = 400;
6
- /**
7
- * Max wall-clock wait for Pusher + batch-details resolution after upload. If exceeded, we stop
8
- * fallback polling, clear the automatching banner (`phase` → completed), and refresh batch list.
9
- */
10
- export declare const BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = 300000;