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

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 (196) 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/aiCfo/aiCfoPayload.d.ts +2 -0
  17. package/lib/entity/aiCfo/aiCfoReducer.d.ts +1 -1
  18. package/lib/entity/aiCfo/aiCfoReducer.js +33 -3
  19. package/lib/entity/aiCfo/aiCfoSelector.js +13 -1
  20. package/lib/entity/aiCfo/aiCfoState.d.ts +2 -0
  21. package/lib/entity/chargeCard/chargeCardReducer.d.ts +19 -2
  22. package/lib/entity/chargeCard/chargeCardReducer.js +35 -2
  23. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +14 -1
  24. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +36 -2
  25. package/lib/entity/class/classSelector.d.ts +35 -0
  26. package/lib/entity/class/classSelector.js +50 -0
  27. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
  28. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  29. package/lib/entity/tenant/SessionManager.js +6 -3
  30. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  31. package/lib/entity/tenant/clearAllEpic.js +2 -2
  32. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  33. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  34. package/lib/entity/tenant/tenantReducer.js +6 -1
  35. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  36. package/lib/epic.d.ts +12 -11
  37. package/lib/epic.js +13 -12
  38. package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
  39. package/lib/esm/commonStateTypes/filterPrimitives.js +20 -0
  40. package/lib/esm/commonStateTypes/pusherActions.js +3 -0
  41. package/lib/esm/coreEpics.js +1 -1
  42. package/lib/esm/entity/account/accountSelector.js +46 -1
  43. package/lib/esm/entity/account/accountState.js +7 -1
  44. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  45. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  46. package/lib/esm/entity/aiCfo/aiCfoReducer.js +32 -2
  47. package/lib/esm/entity/aiCfo/aiCfoSelector.js +13 -1
  48. package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
  49. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
  50. package/lib/esm/entity/class/classSelector.js +48 -0
  51. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  52. package/lib/esm/entity/tenant/SessionManager.js +4 -1
  53. package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
  54. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  55. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  56. package/lib/esm/entity/tenant/tenantReducer.js +6 -1
  57. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  58. package/lib/esm/epic.js +13 -12
  59. package/lib/esm/index.js +33 -23
  60. package/lib/esm/reducer.js +2 -2
  61. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  62. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  63. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  64. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +11 -1
  65. package/lib/esm/view/aiCfoView/epics/updateChatSessionPinEpic.js +46 -0
  66. package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  67. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  68. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
  69. package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
  70. package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
  71. package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  72. package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +1 -16
  73. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  74. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  75. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  76. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  77. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
  78. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
  79. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  80. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  81. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +147 -13
  82. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +258 -0
  83. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
  84. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
  85. package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
  86. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +87 -0
  87. package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
  88. package/lib/esm/view/recommendation/recommendationReducer.js +26 -1
  89. package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  90. package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  91. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  92. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  93. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  94. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -9
  95. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  96. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  97. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  98. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  99. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  100. package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
  101. package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
  102. package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
  103. package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
  104. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
  105. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +121 -6
  106. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +29 -1
  107. package/lib/index.d.ts +33 -26
  108. package/lib/index.js +86 -60
  109. package/lib/reducer.d.ts +2 -2
  110. package/lib/reducer.js +2 -2
  111. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
  112. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
  113. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  114. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  115. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  116. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +4 -1
  117. package/lib/view/aiCfoView/aiCfoViewReducer.js +12 -2
  118. package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.d.ts +8 -0
  119. package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.js +50 -0
  120. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  121. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
  122. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  123. package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
  124. package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
  125. package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  126. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  127. package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +0 -3
  128. package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -1
  129. package/lib/view/creditAgentView/creditAgentViewReducer.js +2 -17
  130. package/lib/view/creditAgentView/creditAgentViewState.d.ts +0 -5
  131. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  132. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  133. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  134. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  135. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  136. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
  137. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
  138. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
  139. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
  140. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
  141. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  142. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +28 -5
  143. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  144. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
  145. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +16 -0
  146. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +7 -1
  147. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +150 -13
  148. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +66 -0
  149. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +262 -0
  150. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
  151. package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
  152. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
  153. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
  154. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +44 -2
  155. package/lib/view/financeStatement/financeStatementSelector.js +1 -1
  156. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
  157. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
  158. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +91 -0
  159. package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
  160. package/lib/view/recommendation/recommendationHelper.js +31 -1
  161. package/lib/view/recommendation/recommendationReducer.d.ts +20 -1
  162. package/lib/view/recommendation/recommendationReducer.js +27 -2
  163. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  164. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +3 -1
  165. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  166. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +3 -1
  167. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  168. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  169. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  170. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  171. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +18 -3
  172. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +27 -10
  173. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  174. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
  175. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +3 -1
  176. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  177. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  178. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +3 -1
  179. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  180. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  181. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +12 -3
  182. package/lib/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  183. package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
  184. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  185. package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
  186. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -1
  187. package/lib/view/transactionDetail/transactionDetailReducer.js +122 -7
  188. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +2 -0
  189. package/lib/view/transactionDetail/transactionDetailSelector.js +31 -2
  190. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
  191. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
  192. package/package.json +9 -4
  193. package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -13
  194. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  195. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +0 -11
  196. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -17
@@ -0,0 +1,17 @@
1
+ import { Draft, PayloadAction } from '@reduxjs/toolkit';
2
+ /**
3
+ * Factory for `fetchXxx` reducers that support Pusher-driven silent refresh.
4
+ * When `cacheOverride=true`, fetchState and error are left untouched so the
5
+ * UI doesn't flash a skeleton. When `false`, `applyTo` runs the normal
6
+ * 'In-Progress' transition.
7
+ */
8
+ export declare const createCacheOverrideFetchReducer: <TState>(applyTo: (draft: Draft<TState>) => void) => {
9
+ prepare: (cacheOverride?: boolean) => {
10
+ payload: {
11
+ cacheOverride: boolean;
12
+ };
13
+ };
14
+ reducer: (draft: Draft<TState>, action: PayloadAction<{
15
+ cacheOverride: boolean;
16
+ }>) => void;
17
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCacheOverrideFetchReducer = void 0;
4
+ /**
5
+ * Factory for `fetchXxx` reducers that support Pusher-driven silent refresh.
6
+ * When `cacheOverride=true`, fetchState and error are left untouched so the
7
+ * UI doesn't flash a skeleton. When `false`, `applyTo` runs the normal
8
+ * 'In-Progress' transition.
9
+ */
10
+ const createCacheOverrideFetchReducer = (applyTo) => ({
11
+ reducer(draft, action) {
12
+ if (action.payload.cacheOverride !== true) {
13
+ applyTo(draft);
14
+ }
15
+ },
16
+ prepare(cacheOverride = false) {
17
+ return { payload: { cacheOverride } };
18
+ },
19
+ });
20
+ exports.createCacheOverrideFetchReducer = createCacheOverrideFetchReducer;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shared filter primitives — used by both Transaction Categorization and
3
+ * Spend Management filter pipelines.
4
+ *
5
+ * These types are deliberately decoupled from any specific feature group:
6
+ *
7
+ * - `CategoryCombinationOperator` is how a `categories[]` array combines
8
+ * (`AND` ⇒ every category must match; `OR` ⇒ any category matches).
9
+ * - `FilterCategoryType` is the input-type tag a filter category uses to
10
+ * pick its value-picker UI (text autocomplete, user picker, date range,
11
+ * number range, plain dropdown).
12
+ *
13
+ * They used to be redeclared locally in both `transactionFilterHelpers.ts`
14
+ * and `spendManagementFilterHelpers.ts` to keep the feature groups
15
+ * independent. Centralising them here is consistent with Route B (which
16
+ * separated the *matching pipelines*, not the *shared primitive types*) and
17
+ * removes the maintenance trap of two identical type definitions drifting
18
+ * apart over time.
19
+ */
20
+ /** How `categories[]` combines: AND requires every category to match, OR requires any. */
21
+ export type CategoryCombinationOperator = 'AND' | 'OR';
22
+ /** Input-type tag a filter category uses to pick its value-picker UI. */
23
+ export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Shared filter primitives — used by both Transaction Categorization and
4
+ * Spend Management filter pipelines.
5
+ *
6
+ * These types are deliberately decoupled from any specific feature group:
7
+ *
8
+ * - `CategoryCombinationOperator` is how a `categories[]` array combines
9
+ * (`AND` ⇒ every category must match; `OR` ⇒ any category matches).
10
+ * - `FilterCategoryType` is the input-type tag a filter category uses to
11
+ * pick its value-picker UI (text autocomplete, user picker, date range,
12
+ * number range, plain dropdown).
13
+ *
14
+ * They used to be redeclared locally in both `transactionFilterHelpers.ts`
15
+ * and `spendManagementFilterHelpers.ts` to keep the feature groups
16
+ * independent. Centralising them here is consistent with Route B (which
17
+ * separated the *matching pipelines*, not the *shared primitive types*) and
18
+ * removes the maintenance trap of two identical type definitions drifting
19
+ * apart over time.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { ChargeCardTransactionPayload } from '../entity/chargeCardTransaction/chargeCardTransactionPayload';
2
+ import { ID } from './common';
3
+ export declare const addChargeCardTransactionFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
4
+ cardId: ID;
5
+ transaction: ChargeCardTransactionPayload;
6
+ }, string>;
7
+ export declare const addDeclinedChargeCardTransactionFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
+ cardId: ID;
9
+ transaction: ChargeCardTransactionPayload;
10
+ declineReason?: string;
11
+ }, string>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDeclinedChargeCardTransactionFromPusher = exports.addChargeCardTransactionFromPusher = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
5
+ exports.addChargeCardTransactionFromPusher = (0, toolkit_1.createAction)('chargeCardDetail/addChargeCardTransactionFromPusher');
6
+ exports.addDeclinedChargeCardTransactionFromPusher = (0, toolkit_1.createAction)('chargeCardDetail/addDeclinedChargeCardTransactionFromPusher');
package/lib/coreEpics.js CHANGED
@@ -23,8 +23,8 @@ const fetchSubscriptionSummaryForTenantEpic_1 = require("./entity/tenant/epic/fe
23
23
  const resendVerifyDeviceOTPEpic_1 = require("./entity/tenant/epic/resendVerifyDeviceOTPEpic");
24
24
  const saveExternalConnectionEpic_1 = require("./entity/tenant/epic/saveExternalConnectionEpic");
25
25
  const sendEmailMagicLinkToUserEpic_1 = require("./entity/tenant/epic/sendEmailMagicLinkToUserEpic");
26
- const signInUserEpic_1 = require("./entity/tenant/epic/signInUserEpic");
27
26
  const sessionHeartbeatEpic_1 = require("./entity/tenant/epic/sessionHeartbeatEpic");
27
+ const signInUserEpic_1 = require("./entity/tenant/epic/signInUserEpic");
28
28
  const signOutUserEpic_1 = require("./entity/tenant/epic/signOutUserEpic");
29
29
  const verifyDeviceWithTwoFAEpic_1 = require("./entity/tenant/epic/verifyDeviceWithTwoFAEpic");
30
30
  // ── Toast Notification Epic ──────────────────────────────────────────
@@ -1,9 +1,9 @@
1
1
  import { AccountsViewParentID } from '../../commonStateTypes/accountView/nestedAccountID';
2
2
  import { ClassesViewParentID } from '../../commonStateTypes/classesView/nestedClassID';
3
- import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
4
3
  import { AdditionalBalancesOptions } from '../../commonStateTypes/coaBalance/additionalBalances/getAdditionalBalances';
5
4
  import { COABalancesFilter } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
6
5
  import { ID } from '../../commonStateTypes/common';
6
+ import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
7
7
  import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
8
8
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
9
9
  import { Account, AccountBase, AccountState, AccountType } from './accountState';
@@ -123,3 +123,29 @@ export declare const getAccountsOrdered: (filter: COABalancesFilter, accountStat
123
123
  export declare const getAccountsByType: (accountState: AccountState, accountTypes: AccountType[]) => Partial<Record<AccountType, Account[]>>;
124
124
  export declare const getAccountIdsForTypes: (accountState: AccountState, accountTypes: AccountType[]) => ID[];
125
125
  export declare const getAccountIdsForLabels: (accountState: AccountState, labels: string[]) => ID[];
126
+ /**
127
+ * Returns all accounts currently in state (single pass over accountsByKey).
128
+ * Use for dropdowns that need account names and types; map to
129
+ * { accountId, accountName, accountType } as needed.
130
+ */
131
+ export declare const getAllAccounts: (accountState: AccountState) => Account[];
132
+ export interface AccountFilterOption {
133
+ accountId: ID;
134
+ accountName: string;
135
+ accountType: AccountType;
136
+ }
137
+ /**
138
+ * Partitions accounts for transaction filter dropdowns: bank/credit_card → paymentAccountNames,
139
+ * all other account types → categoryOptions. Use for payment_account_name and category filter options.
140
+ *
141
+ * Memoised via `createSelector` so the composite `{categoryOptions,
142
+ * paymentAccountNames}` keeps a stable identity across Redux dispatches that
143
+ * don't change account data. Without this, every consumer using
144
+ * `useSelector(state => getTransactionFilterAccountOptions(state.accountState))`
145
+ * would re-render on every dispatch (the inline call returns a fresh outer
146
+ * object each time, defeating reference equality).
147
+ */
148
+ export declare const getTransactionFilterAccountOptions: (accountState: AccountState) => {
149
+ categoryOptions: AccountFilterOption[];
150
+ paymentAccountNames: AccountFilterOption[];
151
+ };
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAccountIdsForLabels = exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountBase = void 0;
6
+ exports.getTransactionFilterAccountOptions = exports.getAllAccounts = exports.getAccountIdsForLabels = exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountBase = void 0;
7
7
  exports.getAccount = getAccount;
8
8
  exports.getAccountWithBalance = getAccountWithBalance;
9
+ const toolkit_1 = require("@reduxjs/toolkit");
9
10
  const flatMap_1 = __importDefault(require("lodash/flatMap"));
10
11
  const coaBalance_1 = require("../../commonStateTypes/coaBalance/coaBalance");
11
12
  const sortBalancesByFreeRangeTotal_1 = require("../../commonStateTypes/coaBalance/sortBalancesByFreeRangeTotal");
@@ -192,3 +193,48 @@ const getAccountIdsForLabels = (accountState, labels) => {
192
193
  return allAccountIdsForLabels;
193
194
  };
194
195
  exports.getAccountIdsForLabels = getAccountIdsForLabels;
196
+ /**
197
+ * Returns all accounts currently in state (single pass over accountsByKey).
198
+ * Use for dropdowns that need account names and types; map to
199
+ * { accountId, accountName, accountType } as needed.
200
+ */
201
+ const getAllAccounts = (accountState) => Object.values(accountState.accountsByKey);
202
+ exports.getAllAccounts = getAllAccounts;
203
+ /**
204
+ * Partitions accounts for transaction filter dropdowns: bank/credit_card → paymentAccountNames,
205
+ * all other account types → categoryOptions. Use for payment_account_name and category filter options.
206
+ *
207
+ * Memoised via `createSelector` so the composite `{categoryOptions,
208
+ * paymentAccountNames}` keeps a stable identity across Redux dispatches that
209
+ * don't change account data. Without this, every consumer using
210
+ * `useSelector(state => getTransactionFilterAccountOptions(state.accountState))`
211
+ * would re-render on every dispatch (the inline call returns a fresh outer
212
+ * object each time, defeating reference equality).
213
+ */
214
+ exports.getTransactionFilterAccountOptions = (0, toolkit_1.createSelector)(
215
+ // Key the memo on the underlying `accountsByKey` record rather than on
216
+ // `getAllAccounts` output: the latter returns a fresh `Object.values(...)`
217
+ // array on every call, which would defeat reselect's reference-equality
218
+ // check and re-run the projection on every dispatch.
219
+ [(accountState) => accountState.accountsByKey], (accountsByKey) => {
220
+ const accounts = Object.values(accountsByKey);
221
+ const paymentAccountNames = [];
222
+ const categoryOptions = [];
223
+ for (const account of accounts) {
224
+ if (account.accountType == null) {
225
+ continue;
226
+ }
227
+ const option = {
228
+ accountId: account.accountId,
229
+ accountName: account.accountName,
230
+ accountType: account.accountType,
231
+ };
232
+ if ((0, accountState_1.isPaymentAccountType)(account.accountType)) {
233
+ paymentAccountNames.push(option);
234
+ }
235
+ else {
236
+ categoryOptions.push(option);
237
+ }
238
+ }
239
+ return { categoryOptions, paymentAccountNames };
240
+ });
@@ -1,16 +1,21 @@
1
1
  import { AccountsViewParentID } from '../../commonStateTypes/accountView/nestedAccountID';
2
2
  import { Balance } from '../../commonStateTypes/balance';
3
3
  import { ClassesViewParentID } from '../../commonStateTypes/classesView/nestedClassID';
4
- import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
5
4
  import { COABalanceGrouped, COABalanceGroupedByPeriod } from '../../commonStateTypes/coaBalance/coaBalance';
6
5
  import { ID } from '../../commonStateTypes/common';
6
+ import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
7
7
  import { RecommendationBase } from '../../commonStateTypes/recommendationBase';
8
8
  import { Status } from '../../commonStateTypes/status';
9
9
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
10
10
  import { ZeniUrl } from '../../zeniUrl';
11
+ export declare const ALL_ACCOUNT_TYPES: readonly ["bank", "credit_card", "expenses", "cogs", "income", "cash_in", "cash_out", "cash_position", "other_income", "other_expense", "accounts_receivable", "other_current_assets", "fixed_assets", "other_assets", "accounts_payable", "other_current_liabilities", "long_term_liabilities", "equity", "current_liabilities", "current_assets"];
11
12
  export declare const toAccountType: (v: string) => "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
12
13
  export type AccountType = ReturnType<typeof toAccountType>;
13
14
  export declare const toAccountTypeStrict: (v: string | null | undefined) => AccountType | undefined;
15
+ /** Account types used for payment-account filters (e.g. transaction filter "payment account name"). */
16
+ export declare const PAYMENT_ACCOUNT_TYPES: readonly ["bank", "credit_card"];
17
+ export type PaymentAccountType = (typeof PAYMENT_ACCOUNT_TYPES)[number];
18
+ export declare function isPaymentAccountType(accountType: AccountType | undefined): accountType is PaymentAccountType;
14
19
  export type UncategorizedAccountTypes = 'expense' | 'income';
15
20
  declare const toAccountLabel: (v: string) => "prepaid_expenses" | "fixed_assets" | "uncategorized_income" | "uncategorized_expense" | "bank_charges_and_fees" | "travel_transportation" | "accrued_expenses";
16
21
  export type AccountLabel = ReturnType<typeof toAccountLabel>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toReconciliationAccountSourceStrict = exports.toReconciliationAccountSource = exports.toAccountLabelStrict = exports.toAccountTypeStrict = exports.toAccountType = void 0;
3
+ exports.toReconciliationAccountSourceStrict = exports.toReconciliationAccountSource = exports.toAccountLabelStrict = exports.PAYMENT_ACCOUNT_TYPES = exports.toAccountTypeStrict = exports.toAccountType = exports.ALL_ACCOUNT_TYPES = void 0;
4
+ exports.isPaymentAccountType = isPaymentAccountType;
4
5
  exports.getAccountKey = getAccountKey;
5
6
  const nestedAccountID_1 = require("../../commonStateTypes/accountView/nestedAccountID");
6
7
  const nestedClassID_1 = require("../../commonStateTypes/classesView/nestedClassID");
7
8
  const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
8
- const ALL_ACCOUNT_TYPES = [
9
+ exports.ALL_ACCOUNT_TYPES = [
9
10
  'bank',
10
11
  'credit_card',
11
12
  'expenses',
@@ -27,10 +28,16 @@ const ALL_ACCOUNT_TYPES = [
27
28
  'current_liabilities',
28
29
  'current_assets',
29
30
  ];
30
- const toAccountType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_ACCOUNT_TYPES);
31
+ const toAccountType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_ACCOUNT_TYPES);
31
32
  exports.toAccountType = toAccountType;
32
- const toAccountTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v ?? '', ALL_ACCOUNT_TYPES);
33
+ const toAccountTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v ?? '', exports.ALL_ACCOUNT_TYPES);
33
34
  exports.toAccountTypeStrict = toAccountTypeStrict;
35
+ /** Account types used for payment-account filters (e.g. transaction filter "payment account name"). */
36
+ exports.PAYMENT_ACCOUNT_TYPES = ['bank', 'credit_card'];
37
+ function isPaymentAccountType(accountType) {
38
+ return (accountType != null &&
39
+ exports.PAYMENT_ACCOUNT_TYPES.includes(accountType));
40
+ }
34
41
  const ALL_ACCOUNT_LABELS = [
35
42
  'uncategorized_income',
36
43
  'uncategorized_expense',
@@ -1,8 +1,8 @@
1
1
  import { AccountsViewParentID, NestedAccountID, NestedAccountIDHierarchy } from '../../commonStateTypes/accountView/nestedAccountID';
2
2
  import { ClassesViewParentID } from '../../commonStateTypes/classesView/nestedClassID';
3
- import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
4
3
  import { AdditionalBalancesOptions } from '../../commonStateTypes/coaBalance/additionalBalances/getAdditionalBalances';
5
4
  import { COABalancesFilter } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
5
+ import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
6
6
  import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
7
7
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
8
8
  import { AccountReport } from './accountSelector';
@@ -22,9 +22,7 @@ const toAccuracyByModel = (accuracyPayload) => {
22
22
  const toAiAccountantEnrollment = (payload) => ({
23
23
  status: (0, aiAccountantCustomerState_1.toAiAccountantEnrollmentStatus)(payload.status),
24
24
  accuracy: toAccuracyByModel(payload.accuracy),
25
- latestTraining: payload.latest_training != null
26
- ? (0, zeniDayJS_1.date)(payload.latest_training)
27
- : undefined,
25
+ latestTraining: payload.latest_training != null ? (0, zeniDayJS_1.date)(payload.latest_training) : undefined,
28
26
  latestTransactionSync: payload.latest_transaction_sync != null
29
27
  ? (0, zeniDayJS_1.date)(payload.latest_transaction_sync)
30
28
  : undefined,
@@ -31,8 +31,7 @@ const aiAccountantCustomer = (0, toolkit_1.createSlice)({
31
31
  const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
32
32
  const jobMap = new Map(existing.map((job) => [job.jobId, job]));
33
33
  mappedJobs.forEach((job) => jobMap.set(job.jobId, job));
34
- draft.jobsByTenantId[action.payload.tenantId] =
35
- Array.from(jobMap.values());
34
+ draft.jobsByTenantId[action.payload.tenantId] = Array.from(jobMap.values());
36
35
  }
37
36
  else {
38
37
  draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
@@ -1,7 +1,7 @@
1
1
  import { ID } from '../../commonStateTypes/common';
2
+ import { ZeniDate } from '../../zeniDayJS';
2
3
  import { User } from '../user/userState';
3
4
  import { UserState } from '../user/userState';
4
- import { ZeniDate } from '../../zeniDayJS';
5
5
  import { AiAccountantCustomerState, AiAccountantEnrollmentStatus, AiAccountantJobStatus, AiAccountantOperationType } from './aiAccountantCustomerState';
6
6
  export interface AiAccountantEnrollmentView {
7
7
  status: AiAccountantEnrollmentStatus;
@@ -50,6 +50,8 @@ export interface ChatSessionPayload {
50
50
  chat_session_summary: string | null;
51
51
  created_at: string;
52
52
  user_id: string;
53
+ is_pinned?: boolean;
54
+ pinned_at?: string | null;
53
55
  }
54
56
  export interface MessagePayload {
55
57
  chat_session_id: string;
@@ -8,7 +8,7 @@ export declare const setNewSession: import("@reduxjs/toolkit").ActionCreatorWith
8
8
  chatSessionId: ID;
9
9
  createdAt: ZeniDate;
10
10
  userId: ID;
11
- }, "aiCfo/setNewSession">, clearSession: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "aiCfo/clearSession">, setSessions: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChatSessionPayload[], "aiCfo/setSessions">, setChatHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
11
+ }, "aiCfo/setNewSession">, clearSession: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "aiCfo/clearSession">, setSessions: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChatSessionPayload[], "aiCfo/setSessions">, mergeChatSessionFromPutResponse: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChatSessionPayload, "aiCfo/mergeChatSessionFromPutResponse">, setChatHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
12
12
  chatSessionId: ID;
13
13
  history: MessagePayload[];
14
14
  isPaginationComplete?: boolean;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.deleteQuestion = exports.clearAiCfo = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAiCfoVisualization = exports.initialAiCfoState = void 0;
4
+ exports.deleteQuestion = exports.clearAiCfo = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.mergeChatSessionFromPutResponse = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAiCfoVisualization = exports.initialAiCfoState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const zeniDayJS_1 = require("../../zeniDayJS");
7
7
  const aiCfoState_1 = require("./aiCfoState");
@@ -241,8 +241,20 @@ const aiCfo = (0, toolkit_1.createSlice)({
241
241
  // Clear any existing partial Q&A for this session
242
242
  draft.partialQuestionAnswers[chat_session_id] = undefined;
243
243
  }
244
+ else {
245
+ const row = draft.aiCfoByChatSessionId[chat_session_id];
246
+ row.chatSession = mergeChatSessionFromPayload(row.chatSession, chatSessionPayload);
247
+ }
244
248
  });
245
249
  },
250
+ mergeChatSessionFromPutResponse(draft, action) {
251
+ const id = action.payload.chat_session_id;
252
+ const row = draft.aiCfoByChatSessionId[id];
253
+ if (row == null) {
254
+ return;
255
+ }
256
+ row.chatSession = mergeChatSessionFromPayload(row.chatSession, action.payload);
257
+ },
246
258
  setChatHistory(draft, action) {
247
259
  const { chatSessionId, history, isPaginationComplete = false, } = action.payload;
248
260
  if (draft.aiCfoByChatSessionId[chatSessionId] == null) {
@@ -484,14 +496,32 @@ const aiCfo = (0, toolkit_1.createSlice)({
484
496
  },
485
497
  },
486
498
  });
499
+ const mergeChatSessionFromPayload = (prev, payload) => {
500
+ const next = { ...prev };
501
+ next.chatSessionSummary =
502
+ payload.chat_session_summary !== undefined
503
+ ? (payload.chat_session_summary ?? undefined)
504
+ : prev.chatSessionSummary;
505
+ if (payload.is_pinned !== undefined) {
506
+ next.isPinned = payload.is_pinned;
507
+ }
508
+ if (payload.pinned_at != null) {
509
+ next.pinnedAt = (0, zeniDayJS_1.date)(payload.pinned_at);
510
+ }
511
+ else if (payload.is_pinned === false) {
512
+ next.pinnedAt = undefined;
513
+ }
514
+ return next;
515
+ };
487
516
  const toChatSession = (chatSessionPayload) => {
488
517
  const { chat_session_id, user_id, created_at, chat_session_summary } = chatSessionPayload;
489
- return {
518
+ const base = {
490
519
  chatSessionId: chat_session_id,
491
520
  userId: user_id,
492
521
  chatSessionSummary: chat_session_summary ?? undefined,
493
522
  createdAt: (0, zeniDayJS_1.date)(created_at),
494
523
  };
524
+ return mergeChatSessionFromPayload(base, chatSessionPayload);
495
525
  };
496
- _a = aiCfo.actions, exports.setNewSession = _a.setNewSession, exports.clearSession = _a.clearSession, exports.setSessions = _a.setSessions, exports.setChatHistory = _a.setChatHistory, exports.upsertAnswerPayload = _a.upsertAnswerPayload, exports.upsertOrAddQuestionAnswerPayload = _a.upsertOrAddQuestionAnswerPayload, exports.addQuestionPayload = _a.addQuestionPayload, exports.clearAiCfo = _a.clearAiCfo, exports.deleteQuestion = _a.deleteQuestion;
526
+ _a = aiCfo.actions, exports.setNewSession = _a.setNewSession, exports.clearSession = _a.clearSession, exports.setSessions = _a.setSessions, exports.mergeChatSessionFromPutResponse = _a.mergeChatSessionFromPutResponse, exports.setChatHistory = _a.setChatHistory, exports.upsertAnswerPayload = _a.upsertAnswerPayload, exports.upsertOrAddQuestionAnswerPayload = _a.upsertOrAddQuestionAnswerPayload, exports.addQuestionPayload = _a.addQuestionPayload, exports.clearAiCfo = _a.clearAiCfo, exports.deleteQuestion = _a.deleteQuestion;
497
527
  exports.default = aiCfo.reducer;
@@ -37,6 +37,18 @@ function getAiCfoSelectorView(state) {
37
37
  .sort((a, b) => a.question.createdAt.valueOf() - b.question.createdAt.valueOf())
38
38
  : [],
39
39
  }))
40
- .sort((a, b) => b.chatSession.createdAt.valueOf() - a.chatSession.createdAt.valueOf());
40
+ .sort((a, b) => {
41
+ const aPinned = a.chatSession.isPinned === true;
42
+ const bPinned = b.chatSession.isPinned === true;
43
+ if (aPinned !== bPinned) {
44
+ return aPinned ? -1 : 1;
45
+ }
46
+ if (aPinned && bPinned) {
47
+ const aPinKey = (a.chatSession.pinnedAt ?? a.chatSession.createdAt).valueOf();
48
+ const bPinKey = (b.chatSession.pinnedAt ?? b.chatSession.createdAt).valueOf();
49
+ return bPinKey - aPinKey;
50
+ }
51
+ return (b.chatSession.createdAt.valueOf() - a.chatSession.createdAt.valueOf());
52
+ });
41
53
  return { allSessionsWithOrderedQuestionAnswers };
42
54
  }
@@ -107,6 +107,8 @@ export interface ChatSession {
107
107
  createdAt: ZeniDate;
108
108
  userId: ID;
109
109
  chatSessionSummary?: string;
110
+ isPinned?: boolean;
111
+ pinnedAt?: ZeniDate;
110
112
  }
111
113
  export interface ChatSessionWithMessages {
112
114
  chatSession: ChatSession;
@@ -1,9 +1,26 @@
1
- import { UpdateType } from '../../commonStateTypes/common';
1
+ import { ID, UpdateType } from '../../commonStateTypes/common';
2
2
  import { ChargeCardState } from './chargeCard';
3
3
  import { ChargeCardPayload } from './chargeCardPayload';
4
4
  export declare const initialState: ChargeCardState;
5
5
  export declare const updateChargeCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCards: ChargeCardPayload[], updateType?: UpdateType | undefined], ChargeCardPayload[], "chargeCard/updateChargeCards", never, {
6
6
  updateType: UpdateType;
7
- }>, updateChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardPayload, "chargeCard/updateChargeCard">, removeChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "chargeCard/removeChargeCard">, clearAllChargeCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCard/clearAllChargeCards">;
7
+ }>, updateChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardPayload, "chargeCard/updateChargeCard">, updateChargeCardStatusFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
+ cardId: ID;
9
+ cardStatus: {
10
+ code: string;
11
+ name: string;
12
+ };
13
+ isLockedByAdmin: boolean | undefined;
14
+ }, "chargeCard/updateChargeCardStatusFromPusher">, updateChargeCardSpendingFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
15
+ cardId: ID;
16
+ currencyCode: string;
17
+ currencySymbol: string;
18
+ balance?: number;
19
+ dailyPurchaseSpends?: number;
20
+ dailyWithdrawals?: number;
21
+ hold?: number;
22
+ monthlyPurchaseSpends?: number;
23
+ monthlyWithdrawals?: number;
24
+ }, "chargeCard/updateChargeCardSpendingFromPusher">, removeChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "chargeCard/removeChargeCard">, clearAllChargeCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCard/clearAllChargeCards">;
8
25
  declare const _default: import("redux").Reducer<ChargeCardState>;
9
26
  export default _default;
@@ -4,9 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.clearAllChargeCards = exports.removeChargeCard = exports.updateChargeCard = exports.updateChargeCards = exports.initialState = void 0;
7
+ exports.clearAllChargeCards = exports.removeChargeCard = exports.updateChargeCardSpendingFromPusher = exports.updateChargeCardStatusFromPusher = exports.updateChargeCard = exports.updateChargeCards = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
+ const amount_1 = require("../../commonStateTypes/amount");
11
+ const chargeCard_1 = require("./chargeCard");
10
12
  const chargeCardPayload_1 = require("./chargeCardPayload");
11
13
  exports.initialState = {
12
14
  chargeCardByID: {},
@@ -42,6 +44,37 @@ const chargeCard = (0, toolkit_1.createSlice)({
42
44
  const latestChargeCard = (0, chargeCardPayload_1.mapChargeCardPayloadToChargeCard)(action.payload);
43
45
  draft.chargeCardByID[latestChargeCard.id] = latestChargeCard;
44
46
  },
47
+ updateChargeCardStatusFromPusher(draft, action) {
48
+ const { cardId, cardStatus, isLockedByAdmin } = action.payload;
49
+ const card = draft.chargeCardByID[cardId];
50
+ if (card != null) {
51
+ card.status = {
52
+ code: (0, chargeCard_1.toCardStatusCodeType)(cardStatus.code),
53
+ name: cardStatus.name,
54
+ };
55
+ if (isLockedByAdmin !== undefined) {
56
+ card.isLockedByAdmin = isLockedByAdmin;
57
+ }
58
+ }
59
+ },
60
+ updateChargeCardSpendingFromPusher(draft, action) {
61
+ const { cardId, currencyCode, currencySymbol } = action.payload;
62
+ const card = draft.chargeCardByID[cardId];
63
+ if (card == null) {
64
+ return;
65
+ }
66
+ const amt = (v) => v !== undefined ? (0, amount_1.toAmount)(v, currencyCode, currencySymbol) : undefined;
67
+ card.balance = amt(action.payload.balance) ?? card.balance;
68
+ card.hold = amt(action.payload.hold) ?? card.hold;
69
+ card.dailyPurchaseSpends =
70
+ amt(action.payload.dailyPurchaseSpends) ?? card.dailyPurchaseSpends;
71
+ card.monthlyPurchaseSpends =
72
+ amt(action.payload.monthlyPurchaseSpends) ?? card.monthlyPurchaseSpends;
73
+ card.dailyWithdrawals =
74
+ amt(action.payload.dailyWithdrawals) ?? card.dailyWithdrawals;
75
+ card.monthlyWithdrawals =
76
+ amt(action.payload.monthlyWithdrawals) ?? card.monthlyWithdrawals;
77
+ },
45
78
  removeChargeCard(draft, action) {
46
79
  delete draft.chargeCardByID[action.payload];
47
80
  },
@@ -50,5 +83,5 @@ const chargeCard = (0, toolkit_1.createSlice)({
50
83
  },
51
84
  },
52
85
  });
53
- _a = chargeCard.actions, exports.updateChargeCards = _a.updateChargeCards, exports.updateChargeCard = _a.updateChargeCard, exports.removeChargeCard = _a.removeChargeCard, exports.clearAllChargeCards = _a.clearAllChargeCards;
86
+ _a = chargeCard.actions, exports.updateChargeCards = _a.updateChargeCards, exports.updateChargeCard = _a.updateChargeCard, exports.updateChargeCardStatusFromPusher = _a.updateChargeCardStatusFromPusher, exports.updateChargeCardSpendingFromPusher = _a.updateChargeCardSpendingFromPusher, exports.removeChargeCard = _a.removeChargeCard, exports.clearAllChargeCards = _a.clearAllChargeCards;
54
87
  exports.default = chargeCard.reducer;
@@ -5,7 +5,20 @@ export declare const initialState: ChargeCardTransactionState;
5
5
  export declare const updateChargeCardTransactions: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardTransactionPayload[], "chargeCardTransaction/updateChargeCardTransactions">, updateChargeCardTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardTransactionPayload, "chargeCardTransaction/updateChargeCardTransaction">, updateChargeCardTransactionAttachments: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
6
6
  data: TransactionReceiptsPayload;
7
7
  transactionId: ID;
8
- }, "chargeCardTransaction/updateChargeCardTransactionAttachments">, removeChargeCardTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "chargeCardTransaction/removeChargeCardTransaction">, removeChargeCardTransactionAttachmentByThirdPartyTransactionId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
+ }, "chargeCardTransaction/updateChargeCardTransactionAttachments">, updateChargeCardTransactionStatusFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
9
+ transactionId: ID;
10
+ transactionStatus: {
11
+ code: string;
12
+ name: string;
13
+ };
14
+ }, "chargeCardTransaction/updateChargeCardTransactionStatusFromPusher">, updateChargeCardTransactionFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
15
+ cardId: ID;
16
+ transaction: ChargeCardTransactionPayload;
17
+ }, "chargeCardTransaction/updateChargeCardTransactionFromPusher">, updateChargeCardTransactionReceiptFromPusher: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
18
+ attachmentFilePaths: string[];
19
+ cardId: ID;
20
+ transactionId: ID;
21
+ }, "chargeCardTransaction/updateChargeCardTransactionReceiptFromPusher">, removeChargeCardTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "chargeCardTransaction/removeChargeCardTransaction">, removeChargeCardTransactionAttachmentByThirdPartyTransactionId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
9
22
  attachmentFileName: string;
10
23
  thirdPartyTransactionId: ID;
11
24
  }, "chargeCardTransaction/removeChargeCardTransactionAttachmentByThirdPartyTransactionId">, clearAllChargeCardTransactions: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardTransaction/clearAllChargeCardTransactions">;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearAllChargeCardTransactions = exports.removeChargeCardTransactionAttachmentByThirdPartyTransactionId = exports.removeChargeCardTransaction = exports.updateChargeCardTransactionAttachments = exports.updateChargeCardTransaction = exports.updateChargeCardTransactions = exports.initialState = void 0;
4
+ exports.clearAllChargeCardTransactions = exports.removeChargeCardTransactionAttachmentByThirdPartyTransactionId = exports.removeChargeCardTransaction = exports.updateChargeCardTransactionReceiptFromPusher = exports.updateChargeCardTransactionFromPusher = exports.updateChargeCardTransactionStatusFromPusher = exports.updateChargeCardTransactionAttachments = exports.updateChargeCardTransaction = exports.updateChargeCardTransactions = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
+ const pusherActions_1 = require("../../commonStateTypes/pusherActions");
7
+ const chargeCardTransaction_1 = require("./chargeCardTransaction");
6
8
  const chargeCardTransactionPayload_1 = require("./chargeCardTransactionPayload");
7
9
  exports.initialState = {
8
10
  chargeCardTransactionById: {},
@@ -50,10 +52,42 @@ const chargeCardTransaction = (0, toolkit_1.createSlice)({
50
52
  }
51
53
  }
52
54
  },
55
+ updateChargeCardTransactionStatusFromPusher(draft, action) {
56
+ const { transactionId, transactionStatus } = action.payload;
57
+ const transaction = draft.chargeCardTransactionById[transactionId];
58
+ if (transaction != null) {
59
+ transaction.transactionStatus = {
60
+ code: (0, chargeCardTransaction_1.toCardTransactionStatusCode)(transactionStatus.code),
61
+ name: transactionStatus.name,
62
+ };
63
+ }
64
+ },
65
+ updateChargeCardTransactionFromPusher(draft, action) {
66
+ const entity = (0, chargeCardTransactionPayload_1.toChargeCardTransaction)(action.payload.transaction);
67
+ draft.chargeCardTransactionById[entity.id] = entity;
68
+ },
69
+ updateChargeCardTransactionReceiptFromPusher(draft, action) {
70
+ const { transactionId, attachmentFilePaths } = action.payload;
71
+ const transaction = draft.chargeCardTransactionById[transactionId];
72
+ if (transaction != null) {
73
+ transaction.attachmentFilePaths = attachmentFilePaths;
74
+ }
75
+ },
53
76
  clearAllChargeCardTransactions(draft) {
54
77
  draft.chargeCardTransactionById = {};
55
78
  },
56
79
  },
80
+ extraReducers: (builder) => {
81
+ builder
82
+ .addCase(pusherActions_1.addChargeCardTransactionFromPusher, (draft, action) => {
83
+ const entity = (0, chargeCardTransactionPayload_1.toChargeCardTransaction)(action.payload.transaction);
84
+ draft.chargeCardTransactionById[entity.id] = entity;
85
+ })
86
+ .addCase(pusherActions_1.addDeclinedChargeCardTransactionFromPusher, (draft, action) => {
87
+ const entity = (0, chargeCardTransactionPayload_1.toChargeCardTransaction)(action.payload.transaction);
88
+ draft.chargeCardTransactionById[entity.id] = entity;
89
+ });
90
+ },
57
91
  });
58
- _a = chargeCardTransaction.actions, exports.updateChargeCardTransactions = _a.updateChargeCardTransactions, exports.updateChargeCardTransaction = _a.updateChargeCardTransaction, exports.updateChargeCardTransactionAttachments = _a.updateChargeCardTransactionAttachments, exports.removeChargeCardTransaction = _a.removeChargeCardTransaction, exports.removeChargeCardTransactionAttachmentByThirdPartyTransactionId = _a.removeChargeCardTransactionAttachmentByThirdPartyTransactionId, exports.clearAllChargeCardTransactions = _a.clearAllChargeCardTransactions;
92
+ _a = chargeCardTransaction.actions, exports.updateChargeCardTransactions = _a.updateChargeCardTransactions, exports.updateChargeCardTransaction = _a.updateChargeCardTransaction, exports.updateChargeCardTransactionAttachments = _a.updateChargeCardTransactionAttachments, exports.updateChargeCardTransactionStatusFromPusher = _a.updateChargeCardTransactionStatusFromPusher, exports.updateChargeCardTransactionFromPusher = _a.updateChargeCardTransactionFromPusher, exports.updateChargeCardTransactionReceiptFromPusher = _a.updateChargeCardTransactionReceiptFromPusher, exports.removeChargeCardTransaction = _a.removeChargeCardTransaction, exports.removeChargeCardTransactionAttachmentByThirdPartyTransactionId = _a.removeChargeCardTransactionAttachmentByThirdPartyTransactionId, exports.clearAllChargeCardTransactions = _a.clearAllChargeCardTransactions;
59
93
  exports.default = chargeCardTransaction.reducer;