@zeniai/client-epic-state 5.0.80 → 5.0.81-beta0ND

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 (222) hide show
  1. package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +17 -0
  2. package/lib/commonStateTypes/cacheOverrideFetchReducer.js +20 -0
  3. package/lib/commonStateTypes/filterPrimitives.d.ts +23 -0
  4. package/lib/commonStateTypes/filterPrimitives.js +21 -0
  5. package/lib/commonStateTypes/pusherActions.d.ts +11 -0
  6. package/lib/commonStateTypes/pusherActions.js +6 -0
  7. package/lib/coreEpics.js +1 -1
  8. package/lib/entity/account/accountSelector.d.ts +27 -1
  9. package/lib/entity/account/accountSelector.js +47 -1
  10. package/lib/entity/account/accountState.d.ts +6 -1
  11. package/lib/entity/account/accountState.js +11 -4
  12. package/lib/entity/account/subAccountSelector.d.ts +1 -1
  13. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  14. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  15. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
  16. package/lib/entity/chargeCard/chargeCardReducer.d.ts +19 -2
  17. package/lib/entity/chargeCard/chargeCardReducer.js +35 -2
  18. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +14 -1
  19. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +36 -2
  20. package/lib/entity/class/classSelector.d.ts +35 -0
  21. package/lib/entity/class/classSelector.js +50 -0
  22. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  23. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  24. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
  25. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  26. package/lib/entity/tenant/SessionManager.js +6 -3
  27. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  28. package/lib/entity/tenant/clearAllEpic.js +2 -2
  29. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  30. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  31. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  32. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  33. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  34. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  35. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  36. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  37. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  38. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  39. package/lib/entity/tenant/tenantReducer.js +71 -6
  40. package/lib/entity/tenant/tenantState.d.ts +1 -0
  41. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  42. package/lib/epic.d.ts +13 -11
  43. package/lib/epic.js +15 -12
  44. package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
  45. package/lib/esm/commonStateTypes/filterPrimitives.js +20 -0
  46. package/lib/esm/commonStateTypes/pusherActions.js +3 -0
  47. package/lib/esm/coreEpics.js +1 -1
  48. package/lib/esm/entity/account/accountSelector.js +46 -1
  49. package/lib/esm/entity/account/accountState.js +7 -1
  50. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  51. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  52. package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
  53. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
  54. package/lib/esm/entity/class/classSelector.js +48 -0
  55. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  56. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  57. package/lib/esm/entity/tenant/SessionManager.js +4 -1
  58. package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
  59. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  60. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  61. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  62. package/lib/esm/entity/tenant/tenantReducer.js +69 -4
  63. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  64. package/lib/esm/epic.js +15 -12
  65. package/lib/esm/index.js +38 -25
  66. package/lib/esm/reducer.js +2 -2
  67. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  68. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  69. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  70. package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  71. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  72. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
  73. package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
  74. package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
  75. package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  76. package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +1 -16
  77. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  78. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  79. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  80. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  81. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
  82. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
  83. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  84. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  85. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +147 -13
  86. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +258 -0
  87. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
  88. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
  89. package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
  90. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +61 -50
  91. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +87 -0
  92. package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
  93. package/lib/esm/view/recommendation/recommendationReducer.js +26 -1
  94. package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  95. package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  96. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  97. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  98. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  99. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -9
  100. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  101. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  102. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  103. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  104. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +49 -0
  105. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +58 -0
  106. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +12 -0
  107. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  108. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +71 -52
  109. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  110. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  111. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  112. package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
  113. package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
  114. package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
  115. package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
  116. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
  117. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +121 -6
  118. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +29 -1
  119. package/lib/index.d.ts +39 -28
  120. package/lib/index.js +97 -60
  121. package/lib/reducer.d.ts +2 -2
  122. package/lib/reducer.js +2 -2
  123. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
  124. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
  125. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  126. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  127. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  128. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  129. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
  130. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  131. package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
  132. package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
  133. package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  134. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  135. package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +0 -3
  136. package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -1
  137. package/lib/view/creditAgentView/creditAgentViewReducer.js +2 -17
  138. package/lib/view/creditAgentView/creditAgentViewState.d.ts +0 -5
  139. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  140. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  141. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  142. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  143. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  144. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
  145. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
  146. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
  147. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
  148. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
  149. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  150. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +28 -5
  151. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  152. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
  153. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +16 -0
  154. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +7 -1
  155. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +150 -13
  156. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +66 -0
  157. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +262 -0
  158. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
  159. package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
  160. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
  161. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
  162. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +44 -2
  163. package/lib/view/financeStatement/financeStatementSelector.js +1 -1
  164. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +25 -2
  165. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +62 -51
  166. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +10 -0
  167. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
  168. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
  169. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +91 -0
  170. package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
  171. package/lib/view/recommendation/recommendationHelper.js +31 -1
  172. package/lib/view/recommendation/recommendationReducer.d.ts +20 -1
  173. package/lib/view/recommendation/recommendationReducer.js +27 -2
  174. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  175. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +3 -1
  176. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  177. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +3 -1
  178. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  179. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  180. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  181. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  182. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +18 -3
  183. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +27 -10
  184. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  185. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
  186. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +3 -1
  187. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  188. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  189. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +3 -1
  190. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  191. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +8 -0
  192. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +53 -0
  193. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +8 -0
  194. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +62 -0
  195. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +27 -0
  196. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +15 -0
  197. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  198. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  199. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +24 -2
  200. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +72 -53
  201. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +4 -0
  202. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  203. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +12 -0
  204. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  205. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  206. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  207. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +12 -3
  208. package/lib/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  209. package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
  210. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  211. package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
  212. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -1
  213. package/lib/view/transactionDetail/transactionDetailReducer.js +122 -7
  214. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +2 -0
  215. package/lib/view/transactionDetail/transactionDetailSelector.js +31 -2
  216. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
  217. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
  218. package/package.json +10 -4
  219. package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -13
  220. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  221. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +0 -11
  222. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -17
@@ -1,5 +1,6 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { mapSortOrderPayloadToSortOrder, } from '../../../../commonPayloadTypes/sortOrderPayload';
3
+ import { addChargeCardTransactionFromPusher, addDeclinedChargeCardTransactionFromPusher, } from '../../../../commonStateTypes/pusherActions';
3
4
  import { toAttachment, } from '../../../../entity/transaction/payloadTypes/attachmentPayload';
4
5
  import { emptyChargeCardDetail, mapChargeCardTransactionStatisticsPayloadToChargeCardTransactionStatistics, toChargeCardTransactionSortKeyType, } from './chargeCardDetail';
5
6
  export const initialState = {
@@ -64,19 +65,30 @@ const chargeCardDetail = createSlice({
64
65
  },
65
66
  fetchChargeCardTransactionList: {
66
67
  reducer(draft, action) {
67
- const { chargeCardId, pageToken, pageTokenType } = action.payload;
68
+ const { chargeCardId, pageToken, pageTokenType, cacheOverride } = action.payload;
68
69
  const existingCardDetail = draft.detailById[chargeCardId] ?? emptyChargeCardDetail;
70
+ const existingUi = existingCardDetail.transactionList.uiState;
71
+ // cacheOverride=true (Pusher): preserve fetchState, error, and scroll
72
+ // to avoid skeleton flash. Normal fetches reset as before.
69
73
  draft.detailById[chargeCardId] = {
70
74
  ...existingCardDetail,
71
75
  transactionList: {
72
76
  ...existingCardDetail.transactionList,
73
- fetchState: 'In-Progress',
74
- error: undefined,
77
+ fetchState: cacheOverride
78
+ ? existingCardDetail.transactionList.fetchState
79
+ : 'In-Progress',
80
+ error: cacheOverride
81
+ ? existingCardDetail.transactionList.error
82
+ : undefined,
75
83
  uiState: {
76
- ...existingCardDetail.transactionList.uiState,
77
- scrollYOffset: existingCardDetail.transactionList.uiState.pageToken === null
78
- ? 0
79
- : existingCardDetail.transactionList.uiState.scrollYOffset,
84
+ ...existingUi,
85
+ // Preserve scroll on silent refresh so users aren't snapped
86
+ // away from their reading position.
87
+ scrollYOffset: cacheOverride
88
+ ? existingUi.scrollYOffset
89
+ : existingUi.pageToken === null
90
+ ? 0
91
+ : existingUi.scrollYOffset,
80
92
  pageToken: pageToken,
81
93
  pageTokenType: pageTokenType,
82
94
  },
@@ -93,18 +105,24 @@ const chargeCardDetail = createSlice({
93
105
  const { chargeCardId, data, cacheOverride } = action.payload;
94
106
  const existingCardDetail = draft.detailById[chargeCardId] ?? emptyChargeCardDetail;
95
107
  const newTransactionIds = data.transactions.map((tran) => tran.transaction_id);
108
+ const existingIds = existingCardDetail.transactionList.transactionIds;
109
+ // cacheOverride (Pusher): refresh page 1 but keep page 2+ IDs.
110
+ // Normal pagination: append new page, deduped.
111
+ const newIdSet = new Set(newTransactionIds);
112
+ const mergedTransactionIds = cacheOverride
113
+ ? [
114
+ ...newTransactionIds,
115
+ ...existingIds.filter((id) => !newIdSet.has(id)),
116
+ ]
117
+ : [
118
+ ...existingIds,
119
+ ...newTransactionIds.filter((id) => !existingIds.includes(id)),
120
+ ];
96
121
  draft.detailById[chargeCardId] = {
97
122
  ...existingCardDetail,
98
123
  transactionList: {
99
124
  ...existingCardDetail.transactionList,
100
- transactionIds: [
101
- ...new Set([
102
- ...(cacheOverride
103
- ? []
104
- : existingCardDetail.transactionList.transactionIds),
105
- ...newTransactionIds,
106
- ]),
107
- ],
125
+ transactionIds: mergedTransactionIds,
108
126
  fetchState: 'Completed',
109
127
  error: undefined,
110
128
  uiState: {
@@ -116,9 +134,12 @@ const chargeCardDetail = createSlice({
116
134
  limit: data.query.limit,
117
135
  pageToken: data.query.page_token,
118
136
  pageTokenType: data.query.page_token_type,
119
- scrollYOffset: existingCardDetail.transactionList.uiState.pageToken === null
120
- ? 0
121
- : existingCardDetail.transactionList.uiState.scrollYOffset,
137
+ // Preserve scroll on silent refresh; reset on user-triggered first page.
138
+ scrollYOffset: cacheOverride
139
+ ? existingCardDetail.transactionList.uiState.scrollYOffset
140
+ : existingCardDetail.transactionList.uiState.pageToken === null
141
+ ? 0
142
+ : existingCardDetail.transactionList.uiState.scrollYOffset,
122
143
  },
123
144
  },
124
145
  };
@@ -632,6 +653,22 @@ const chargeCardDetail = createSlice({
632
653
  Object.assign(draft, initialState);
633
654
  },
634
655
  },
656
+ extraReducers: (builder) => {
657
+ const prependTransaction = (draft, cardId, txId) => {
658
+ const detail = draft.detailById[cardId];
659
+ if (detail != null &&
660
+ !detail.transactionList.transactionIds.includes(txId)) {
661
+ detail.transactionList.transactionIds.unshift(txId);
662
+ }
663
+ };
664
+ builder
665
+ .addCase(addChargeCardTransactionFromPusher, (draft, action) => {
666
+ prependTransaction(draft, action.payload.cardId, action.payload.transaction.transaction_id);
667
+ })
668
+ .addCase(addDeclinedChargeCardTransactionFromPusher, (draft, action) => {
669
+ prependTransaction(draft, action.payload.cardId, action.payload.transaction.transaction_id);
670
+ });
671
+ },
635
672
  });
636
673
  export const { fetchChargeCardDetailPage, fetchChargeCardDetail, updateChargeCardDetailFetchState, fetchChargeCardTransactionList, updateChargeCardDetailUIState, updateChargeCardTransactionList, updateChargeCardTransactionUploadReceiptsFetchStatus, fetchChargeCardTransactionAttachments, updateChargeCardTransactionIsViewReceiptClicked, updateChargeCardTransactionAttachmentsFailure, updatePhysicalChargeCardAttemptSuccessOrFailure, updatePhysicalChargeCardAttempt, updateDebitCardPinAttempt, updateDebitCardPinAttemptSuccessOrFailure, updateChargeCardTransactionReceiptsShowTickFetchStatus, updateChargeCardTransactionAttachmentsInCardDetail, updateChargeCardTransactionListFailure, updateChargeCardDetail, startCVVActivationWait, completeCVVActivationWait, startDebitCardSetPinWait, completeDebitCardSetPinWait, updateChargeCardDetailUpdateStatus, updateChargeCardSpendLimit, updateChargeCardSpendLimitSuccessOrFailure, updateChargeCardName, updateChargeCardNameSuccessOrFailure, lockChargeCard, lockChargeCardSuccessOrFailure, unlockChargeCard, unlockChargeCardSuccessOrFailure, closeChargeCard, closeChargeCardSuccessOrFailure, fetchDepositAccountLimit, updateDepositAccountLimitFetchStatus, fetchChargeCardTransactionStatistics, updateChargeCardTransactionStatistics, updateChargeCardTransactionStatisticsFetchState, fetchChargeCardsRecurringExpenses, updateChargeCardsRecurringExpenses, updateChargeCardsRecurringExpensesFetchState, sendOtpCardHolder, resendOtpCardHolder, sendOtpCardHolderSuccess, sendOtpCardHolderFailure, verifyOtpCardHolder, verifyOtpCardHolderSuccess, verifyOtpCardHolderFailure, clearChargeCardDetail, } = chargeCardDetail.actions;
637
674
  export default chargeCardDetail.reducer;
@@ -13,13 +13,24 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
13
13
  const chargeCardAction = [];
14
14
  const state = state$.value;
15
15
  const chargeCardDetail = recordGet(state.chargeCardDetailState.detailById, chargeCardId, undefined);
16
+ // Skip if a user-triggered fetch is already in-flight (not applicable
17
+ // to cacheOverride/Pusher refreshes, which always proceed).
16
18
  if (cacheOverride === true ||
17
19
  chargeCardDetail == null ||
18
20
  chargeCardDetail.fetchState !== 'In-Progress') {
21
+ // Silent refresh: preserve fetchState to avoid skeleton flash.
22
+ // Discriminate via fetchState (not null-check) because the reducer
23
+ // always creates an entry before the epic runs.
24
+ const isSilentRefresh = cacheOverride === true &&
25
+ chargeCardDetail != null &&
26
+ chargeCardDetail.fetchState !== 'Not-Started';
19
27
  chargeCardAction.push(updateChargeCardDetailFetchState({
20
28
  chargeCardId,
21
- isRefreshingViewInBackground: cacheOverride,
22
- fetchState: 'In-Progress',
29
+ isRefreshingViewInBackground: isSilentRefresh,
30
+ fetchState: isSilentRefresh
31
+ ? chargeCardDetail.fetchState
32
+ : 'In-Progress',
33
+ error: isSilentRefresh ? chargeCardDetail.error : undefined,
23
34
  }));
24
35
  const query = {
25
36
  is_include_card_activation_events: true,
@@ -37,6 +48,8 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
37
48
  }));
38
49
  }
39
50
  else {
51
+ // Surface errors even on silent refresh so the user
52
+ // knows data is stale (follow-up: consider toast instead).
40
53
  return of(updateChargeCardDetailFetchState({
41
54
  chargeCardId,
42
55
  fetchState: 'Error',
@@ -45,6 +58,7 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
45
58
  }));
46
59
  }
47
60
  }), catchError((error) => {
61
+ // Surface network failures even on silent refresh.
48
62
  return of(updateChargeCardDetailFetchState({
49
63
  chargeCardId,
50
64
  fetchState: 'Error',
@@ -15,15 +15,16 @@ export const fetchChargeCardDetailPageEpic = (actions$, state$) => actions$.pipe
15
15
  ? exsitingChargeCardDetail.transactionList.uiState.pageTokenType
16
16
  : null;
17
17
  if (cacheOverride === true) {
18
+ // Forward cacheOverride to all sub-fetches to prevent skeleton flash.
18
19
  chargeCardTransactionListAction.push(fetchChargeCardDetail(chargeCardId, cacheOverride));
19
20
  //latest transactions need to be fetched hence removing pageToken and pageTokenType
20
- chargeCardTransactionListAction.push(fetchChargeCardTransactionList(chargeCardId, null, null));
21
- chargeCardTransactionListAction.push(fetchChargeCardConfig());
21
+ chargeCardTransactionListAction.push(fetchChargeCardTransactionList(chargeCardId, null, null, true));
22
+ chargeCardTransactionListAction.push(fetchChargeCardConfig(true));
22
23
  if (doFetchCreditAccounts && isCreditCardEnabled) {
23
- chargeCardTransactionListAction.push(fetchCreditAccount());
24
+ chargeCardTransactionListAction.push(fetchCreditAccount(true));
24
25
  }
25
26
  if (doFetchCreditAccounts && isCreditCardEnabled) {
26
- chargeCardTransactionListAction.push(fetchCreditAccountRepayment());
27
+ chargeCardTransactionListAction.push(fetchCreditAccountRepayment(true));
27
28
  }
28
29
  }
29
30
  else {
@@ -1,5 +1,6 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { toAmount } from '../../../../commonStateTypes/amount';
3
+ import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
3
4
  import { date } from '../../../../zeniDayJS';
4
5
  import { initialCreditAcc, initialCreditAccountRepayment, initialDebitCardSummaries, initialResendRevokeCardInvite, toCreditAccountStatusType, } from './chargeCardList';
5
6
  export const initialState = {
@@ -43,6 +44,10 @@ export const initialState = {
43
44
  revokeCardInvite: initialResendRevokeCardInvite,
44
45
  creditAccountRepayment: initialCreditAccountRepayment,
45
46
  };
47
+ // Silent-Pusher-refresh contract: when cacheOverride=true, fetch reducers
48
+ // leave fetchState and error unchanged so the list page's reduceFetchState
49
+ // selector stays 'Completed' and doesn't flash ChargeCardListLoading.
50
+ // See createCacheOverrideFetchReducer for details.
46
51
  const chargeCardList = createSlice({
47
52
  name: 'chargeCardList',
48
53
  initialState,
@@ -62,10 +67,10 @@ const chargeCardList = createSlice({
62
67
  };
63
68
  },
64
69
  },
65
- fetchCreditAccountRepayment(draft) {
70
+ fetchCreditAccountRepayment: createCacheOverrideFetchReducer((draft) => {
66
71
  draft.creditAccountRepayment.fetchState = 'In-Progress';
67
72
  draft.creditAccountRepayment.error = undefined;
68
- },
73
+ }),
69
74
  updateCreditAccountRepaymentAmountAndDate(draft, action) {
70
75
  draft.creditAccountRepayment.initiatedRepayments = action.payload.amount;
71
76
  draft.creditAccountRepayment.initiatedRepaymentDate = action.payload.date;
@@ -83,10 +88,10 @@ const chargeCardList = createSlice({
83
88
  updateRowActionCardId(draft, action) {
84
89
  draft.rowActionCardId = action.payload;
85
90
  },
86
- fetchCreditAccount(draft) {
91
+ fetchCreditAccount: createCacheOverrideFetchReducer((draft) => {
87
92
  draft.creditAccount.fetchState = 'In-Progress';
88
93
  draft.creditAccount.error = undefined;
89
- },
94
+ }),
90
95
  updateCreditAccount(draft, action) {
91
96
  if (action.payload.length > 0) {
92
97
  draft.creditAccount = toCreditAccount(action.payload[0]);
@@ -99,10 +104,10 @@ const chargeCardList = createSlice({
99
104
  error: action.payload,
100
105
  };
101
106
  },
102
- fetchDebitCardSummary(draft) {
107
+ fetchDebitCardSummary: createCacheOverrideFetchReducer((draft) => {
103
108
  draft.debitCardSummaries.fetchState = 'In-Progress';
104
109
  draft.debitCardSummaries.error = undefined;
105
- },
110
+ }),
106
111
  updateDebitCardSummary(draft, action) {
107
112
  draft.debitCardSummaries = toDebitCardSummaries(action.payload);
108
113
  },
@@ -113,10 +118,10 @@ const chargeCardList = createSlice({
113
118
  error: action.payload,
114
119
  };
115
120
  },
116
- fetchChargeCardList(draft) {
121
+ fetchChargeCardList: createCacheOverrideFetchReducer((draft) => {
117
122
  draft.fetchState = 'In-Progress';
118
123
  draft.error = undefined;
119
- },
124
+ }),
120
125
  updateChargeCardList(draft, action) {
121
126
  const { cards, unassigned_credit } = action.payload.chargeCardListPayload;
122
127
  const newCard = cards.map((card) => card.card_id);
@@ -152,6 +157,18 @@ const chargeCardList = createSlice({
152
157
  draft.uiState.scrollYOffset = action.payload.uiState.scrollYOffset;
153
158
  }
154
159
  },
160
+ updateCreditAccountBalanceFromPusher(draft, action) {
161
+ const { currencyCode, currencySymbol } = action.payload;
162
+ const amt = (v) => v !== undefined ? toAmount(v, currencyCode, currencySymbol) : undefined;
163
+ draft.creditAccount.available =
164
+ amt(action.payload.available) ?? draft.creditAccount.available;
165
+ draft.creditAccount.balance =
166
+ amt(action.payload.balance) ?? draft.creditAccount.balance;
167
+ draft.creditAccount.hold =
168
+ amt(action.payload.hold) ?? draft.creditAccount.hold;
169
+ draft.creditAccount.cashback =
170
+ amt(action.payload.cashback) ?? draft.creditAccount.cashback;
171
+ },
155
172
  clearChargeCardList(draft) {
156
173
  Object.assign(draft, initialState);
157
174
  },
@@ -307,7 +324,7 @@ const chargeCardList = createSlice({
307
324
  },
308
325
  },
309
326
  });
310
- export const { fetchChargeCardListPage, fetchCreditAccountRepayment, updateCreditAccountRepayment, updateCreditAccountRepaymentFailure, updateCreditAccountRepaymentAmountAndDate, updateRowActionCardId, fetchCreditAccount, updateCreditAccount, updateCreditAccountFailure, fetchDebitCardSummary, updateDebitCardSummary, updateDebitCardSummaryFailure, fetchChargeCardList, updateChargeCardList, updateChargeCardListFailure, updateSearchText, updateBulkActionCardIds, updateChargeCardListUIState, clearChargeCardList, resendCardInvite, resendCardInviteSuccess, resendCardInviteFailure, revokeCardInvite, revokeCardInviteSuccess, revokeCardInviteFailure, updateChargeCardsSpendLimit, updateChargeCardsSpendLimitSuccessOrFailure, lockChargeCards, lockChargeCardsSuccessOrFailure, unlockChargeCards, unlockChargeCardsSuccessOrFailure, closeChargeCards, closeChargeCardsSuccessOrFailure, revokeChargeCardsInvite, revokeChargeCardsInviteSuccessOrFailure, } = chargeCardList.actions;
327
+ export const { fetchChargeCardListPage, fetchCreditAccountRepayment, updateCreditAccountRepayment, updateCreditAccountRepaymentFailure, updateCreditAccountRepaymentAmountAndDate, updateRowActionCardId, fetchCreditAccount, updateCreditAccount, updateCreditAccountFailure, fetchDebitCardSummary, updateDebitCardSummary, updateDebitCardSummaryFailure, fetchChargeCardList, updateChargeCardList, updateChargeCardListFailure, updateSearchText, updateBulkActionCardIds, updateChargeCardListUIState, updateCreditAccountBalanceFromPusher, clearChargeCardList, resendCardInvite, resendCardInviteSuccess, resendCardInviteFailure, revokeCardInvite, revokeCardInviteSuccess, revokeCardInviteFailure, updateChargeCardsSpendLimit, updateChargeCardsSpendLimitSuccessOrFailure, lockChargeCards, lockChargeCardsSuccessOrFailure, unlockChargeCards, unlockChargeCardsSuccessOrFailure, closeChargeCards, closeChargeCardsSuccessOrFailure, revokeChargeCardsInvite, revokeChargeCardsInviteSuccessOrFailure, } = chargeCardList.actions;
311
328
  export default chargeCardList.reducer;
312
329
  // helper
313
330
  const toCreditAccount = (payload) => ({
@@ -14,18 +14,21 @@ export const fetchChargeCardListPageEpic = (actions$, state$) => actions$.pipe(f
14
14
  const state = state$.value;
15
15
  const cashbackDetailState = state.cashbackDetailState;
16
16
  if (cacheOverride === true) {
17
+ // Forward cacheOverride to all sub-fetches to prevent skeleton flash.
17
18
  if (doFetchCreditAccountsDebitSummaryAndCashback === true) {
18
19
  if (isCreditCardEnabled) {
19
- chargeCardListPageAction.push(fetchCreditAccount());
20
- chargeCardListPageAction.push(fetchCreditAccountRepayment());
20
+ chargeCardListPageAction.push(fetchCreditAccount(true));
21
+ chargeCardListPageAction.push(fetchCreditAccountRepayment(true));
21
22
  }
22
23
  if (isDebitCardEnabled) {
23
- chargeCardListPageAction.push(fetchDebitCardSummary());
24
+ chargeCardListPageAction.push(fetchDebitCardSummary(true));
24
25
  }
25
- chargeCardListPageAction.push(fetchCashbackDetail());
26
+ chargeCardListPageAction.push(fetchCashbackDetail(true));
26
27
  }
27
- chargeCardListPageAction.push(fetchChargeCardList());
28
- chargeCardListPageAction.push(fetchChargeCardConfig());
28
+ chargeCardListPageAction.push(fetchChargeCardList(true));
29
+ // Config participates in the list page's reduceFetchState — needs cacheOverride.
30
+ chargeCardListPageAction.push(fetchChargeCardConfig(true));
31
+ // These don't participate in the list page's reduceFetchState.
29
32
  chargeCardListPageAction.push(fetchUserListByType('cardHolderCandidate', true));
30
33
  chargeCardListPageAction.push(fetchUserListByType('cardAdmin', true));
31
34
  chargeCardListPageAction.push(fetchClassList());
@@ -1,4 +1,5 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
+ import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
2
3
  import { initialChargeCardPaymentHistoryState, } from './chargeCardPaymentHistory';
3
4
  export const initialState = initialChargeCardPaymentHistoryState;
4
5
  const chargeCardPaymentHistory = createSlice({
@@ -17,10 +18,10 @@ const chargeCardPaymentHistory = createSlice({
17
18
  };
18
19
  },
19
20
  },
20
- fetchChargeCardPaymentHistory(draft) {
21
+ fetchChargeCardPaymentHistory: createCacheOverrideFetchReducer((draft) => {
21
22
  draft.fetchState = 'In-Progress';
22
23
  draft.error = undefined;
23
- },
24
+ }),
24
25
  updateChargeCardPaymentHistory(draft, action) {
25
26
  const payload = action.payload;
26
27
  draft.creditAccountId = payload.credit_account_id;
@@ -8,7 +8,7 @@ export const fetchChargeCardPaymentPageEpic = (actions$, state$) => actions$.pip
8
8
  const state = state$.value;
9
9
  const chargeCardPaymentHistoryState = state.chargeCardPaymentHistoryState;
10
10
  if (cacheOverride === true) {
11
- chargeCardPaymentPageActions.push(fetchChargeCardPaymentHistory());
11
+ chargeCardPaymentPageActions.push(fetchChargeCardPaymentHistory(true));
12
12
  }
13
13
  else {
14
14
  if (chargeCardPaymentHistoryState.fetchState !== 'Completed' &&
@@ -1,4 +1,5 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
+ import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
2
3
  export const initialState = {
3
4
  localData: {
4
5
  amount: {
@@ -17,9 +18,12 @@ const chargeCardRepaymentDetail = createSlice({
17
18
  name: 'chargeCardRepaymentDetail',
18
19
  initialState,
19
20
  reducers: {
20
- fetchChargeCardRepaymentDetail() {
21
- //do nothing
22
- },
21
+ // No-op reducer — fetchState is managed by the Pay flow reducers.
22
+ // Uses createCacheOverrideFetchReducer for API consistency with the
23
+ // silent-refresh family (cacheOverride flag at dispatch site).
24
+ fetchChargeCardRepaymentDetail: createCacheOverrideFetchReducer(() => {
25
+ // do nothing
26
+ }),
23
27
  updateChargeCardRepaymentLocalStore(draft, action) {
24
28
  draft.localData = action.payload;
25
29
  },
@@ -0,0 +1,49 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { isSuccessResponse } from '../../../../../responsePayload';
4
+ import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
+ import { parseUploadedKybDocument } from '../../kycKybAutofillActions';
6
+ import { mapCoiToCompanyDetails, mapTaxEinToCompanyDetails, } from '../../kycKybParseMapper';
7
+ import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
8
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
9
+ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseUploadedKybDocument.match), mergeMap((action) => {
10
+ const { target, companyId, fileId, documentType } = action.payload;
11
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
12
+ const requestPayload = {
13
+ provided_document_type: documentType,
14
+ files: [{ file_id: fileId }],
15
+ processing_priority: 10,
16
+ metadata: { source: 'kyc_kyb_autofill' },
17
+ };
18
+ return zeniAPI
19
+ .postAndGetJSON(url, requestPayload)
20
+ .pipe(mergeMap((response) => {
21
+ if (!isSuccessResponse(response) || response.data == null) {
22
+ return of();
23
+ }
24
+ let result;
25
+ switch (documentType) {
26
+ case 'certificate_of_incorporation':
27
+ result = mapCoiToCompanyDetails(response.data);
28
+ break;
29
+ case 'tax_ein':
30
+ result = mapTaxEinToCompanyDetails(response.data);
31
+ break;
32
+ }
33
+ if (result.autoFilledFieldNames.length === 0) {
34
+ return of();
35
+ }
36
+ const applyAction = target === 'setup'
37
+ ? applyKybDocumentAutofillForSetup({
38
+ companyId,
39
+ values: result.values,
40
+ autoFilledFieldNames: result.autoFilledFieldNames,
41
+ })
42
+ : applyKybDocumentAutofillForOnboarding({
43
+ companyId,
44
+ values: result.values,
45
+ autoFilledFieldNames: result.autoFilledFieldNames,
46
+ });
47
+ return of(applyAction);
48
+ }), catchError(() => of()));
49
+ }));
@@ -0,0 +1,58 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
4
+ import { isSuccessResponse } from '../../../../../responsePayload';
5
+ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
+ import { parseUploadedKycDocument } from '../../kycKybAutofillActions';
7
+ import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
8
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
9
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
10
+ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(parseUploadedKycDocument.match), mergeMap((action) => {
11
+ const { target, companyId, officerType, fileId, documentType } = action.payload;
12
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
13
+ const requestPayload = {
14
+ provided_document_type: documentType,
15
+ files: [{ file_id: fileId }],
16
+ processing_priority: 10,
17
+ metadata: { source: 'kyc_kyb_autofill' },
18
+ };
19
+ return zeniAPI
20
+ .postAndGetJSON(url, requestPayload)
21
+ .pipe(mergeMap((response) => {
22
+ if (!isSuccessResponse(response) || response.data == null) {
23
+ return of();
24
+ }
25
+ const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
26
+ let result;
27
+ switch (documentType) {
28
+ case 'passport':
29
+ result = mapPassportToOfficer(response.data, allCountries);
30
+ break;
31
+ case 'driving_license':
32
+ result = mapDrivingLicenseToOfficer(response.data);
33
+ break;
34
+ case 'social_security_card':
35
+ result = mapSsnCardToOfficer(response.data);
36
+ break;
37
+ }
38
+ if (result.autoFilledFieldNames.length === 0) {
39
+ return of();
40
+ }
41
+ const applyAction = target === 'setup'
42
+ ? applyKycDocumentAutofillForSetup({
43
+ companyId,
44
+ officerType,
45
+ values: result.values,
46
+ autoFilledFieldNames: result.autoFilledFieldNames,
47
+ })
48
+ : applyKycDocumentAutofillForOnboarding({
49
+ companyId,
50
+ officerType,
51
+ values: result.values,
52
+ autoFilledFieldNames: result.autoFilledFieldNames,
53
+ });
54
+ return of(applyAction);
55
+ }), catchError(() =>
56
+ // Autofill is best-effort; swallow errors silently so the user can keep typing.
57
+ of()));
58
+ }));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Trigger actions for the KYC / KYB autofill epics.
3
+ *
4
+ * These actions don't mutate state — the epic listens for them, calls
5
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
6
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
7
+ * slice. Co-located with the rest of the commonSetup module because the entire
8
+ * autofill flow is auxiliary to the setup view; there is no separate state.
9
+ */
10
+ import { createAction } from '@reduxjs/toolkit';
11
+ export const parseUploadedKycDocument = createAction('commonSetup/parseUploadedKycDocument');
12
+ export const parseUploadedKybDocument = createAction('commonSetup/parseUploadedKybDocument');