@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.
- package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +17 -0
- package/lib/commonStateTypes/cacheOverrideFetchReducer.js +20 -0
- package/lib/commonStateTypes/filterPrimitives.d.ts +23 -0
- package/lib/commonStateTypes/filterPrimitives.js +21 -0
- package/lib/commonStateTypes/pusherActions.d.ts +11 -0
- package/lib/commonStateTypes/pusherActions.js +6 -0
- package/lib/coreEpics.js +1 -1
- package/lib/entity/account/accountSelector.d.ts +27 -1
- package/lib/entity/account/accountSelector.js +47 -1
- package/lib/entity/account/accountState.d.ts +6 -1
- package/lib/entity/account/accountState.js +11 -4
- package/lib/entity/account/subAccountSelector.d.ts +1 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +2 -0
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +1 -1
- package/lib/entity/aiCfo/aiCfoReducer.js +33 -3
- package/lib/entity/aiCfo/aiCfoSelector.js +13 -1
- package/lib/entity/aiCfo/aiCfoState.d.ts +2 -0
- package/lib/entity/chargeCard/chargeCardReducer.d.ts +19 -2
- package/lib/entity/chargeCard/chargeCardReducer.js +35 -2
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +14 -1
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +36 -2
- package/lib/entity/class/classSelector.d.ts +35 -0
- package/lib/entity/class/classSelector.js +50 -0
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/entity/tenant/SessionManager.js +6 -3
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.js +2 -2
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
- package/lib/entity/tenant/tenantReducer.js +6 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
- package/lib/epic.d.ts +12 -11
- package/lib/epic.js +13 -12
- package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
- package/lib/esm/commonStateTypes/filterPrimitives.js +20 -0
- package/lib/esm/commonStateTypes/pusherActions.js +3 -0
- package/lib/esm/coreEpics.js +1 -1
- package/lib/esm/entity/account/accountSelector.js +46 -1
- package/lib/esm/entity/account/accountState.js +7 -1
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +32 -2
- package/lib/esm/entity/aiCfo/aiCfoSelector.js +13 -1
- package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
- package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
- package/lib/esm/entity/class/classSelector.js +48 -0
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/esm/entity/tenant/SessionManager.js +4 -1
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
- package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
- package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
- package/lib/esm/entity/tenant/tenantReducer.js +6 -1
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
- package/lib/esm/epic.js +13 -12
- package/lib/esm/index.js +33 -23
- package/lib/esm/reducer.js +2 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +11 -1
- package/lib/esm/view/aiCfoView/epics/updateChatSessionPinEpic.js +46 -0
- package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
- package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +1 -16
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +147 -13
- package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +258 -0
- package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
- package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +87 -0
- package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
- package/lib/esm/view/recommendation/recommendationReducer.js +26 -1
- package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -9
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +4 -2
- package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +121 -6
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +29 -1
- package/lib/index.d.ts +33 -26
- package/lib/index.js +86 -60
- package/lib/reducer.d.ts +2 -2
- package/lib/reducer.js +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
- package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +4 -1
- package/lib/view/aiCfoView/aiCfoViewReducer.js +12 -2
- package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.d.ts +8 -0
- package/lib/view/aiCfoView/epics/updateChatSessionPinEpic.js +50 -0
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +0 -3
- package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -1
- package/lib/view/creditAgentView/creditAgentViewReducer.js +2 -17
- package/lib/view/creditAgentView/creditAgentViewState.d.ts +0 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +28 -5
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +16 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +7 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +150 -13
- package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +66 -0
- package/lib/view/expenseAutomationView/transactionFilterHelpers.js +262 -0
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
- package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +44 -2
- package/lib/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +91 -0
- package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
- package/lib/view/recommendation/recommendationHelper.js +31 -1
- package/lib/view/recommendation/recommendationReducer.d.ts +20 -1
- package/lib/view/recommendation/recommendationReducer.js +27 -2
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +18 -3
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +27 -10
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +12 -3
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +4 -2
- package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -1
- package/lib/view/transactionDetail/transactionDetailReducer.js +122 -7
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +2 -0
- package/lib/view/transactionDetail/transactionDetailSelector.js +31 -2
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
- package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
- package/package.json +9 -4
- package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -13
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +0 -11
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -17
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { transformRecommendation, transformRecommendationWithCOT, } from '../../entity/transaction/payloadTypes/transactionPayload';
|
|
2
|
+
import { getActualTransactionID } from '../transactionDetail/transactionDetailState';
|
|
2
3
|
export const getRecommendationFromRecommendationPayload = (payload) => {
|
|
3
4
|
if (payload == null || payload.length === 0) {
|
|
4
5
|
return undefined;
|
|
@@ -37,6 +38,34 @@ export const getRecommendationWithCOTFromRecommendationPayloadWithCOT = (payload
|
|
|
37
38
|
});
|
|
38
39
|
return recommendations;
|
|
39
40
|
};
|
|
41
|
+
// Pluralized URL segment for entity types. Mirrors the legacy
|
|
42
|
+
// fetchEntityRecommendationsByTransactionIdEpic.toEntityTypeURL.
|
|
43
|
+
const toEntityTypeUrlSegment = (entityType) => `${entityType}s`;
|
|
44
|
+
// Build the recommendations URL for a single entity + transaction target.
|
|
45
|
+
// Centralizes the URL shape so the legacy
|
|
46
|
+
// fetchEntityRecommendationsByTransactionIdEpic and the new
|
|
47
|
+
// fetchEntityRecommendationsForLineUpdateEpic stay in lockstep.
|
|
48
|
+
export const buildRecommendationUrl = (accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT) => {
|
|
49
|
+
const entityQuery = {
|
|
50
|
+
entity_name: entity.name,
|
|
51
|
+
entity_type: entity.type,
|
|
52
|
+
};
|
|
53
|
+
// Entity-id-null case: server expects entity_name / entity_type query
|
|
54
|
+
// instead of the {entityType}/{qboId}/recommendations path.
|
|
55
|
+
if (entity.qboId === entity.name) {
|
|
56
|
+
return `${accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(entityQuery))}`;
|
|
57
|
+
}
|
|
58
|
+
const query = {
|
|
59
|
+
amount,
|
|
60
|
+
transaction_id: getActualTransactionID(transactionDetails.transactionId.id),
|
|
61
|
+
transaction_type: transactionDetails.transaction.type,
|
|
62
|
+
line_ids: transactionDetails.lineIds,
|
|
63
|
+
};
|
|
64
|
+
if (isFetchCOT === true) {
|
|
65
|
+
query.include_cot = true;
|
|
66
|
+
}
|
|
67
|
+
return `${accountMicroServiceBaseUrl}/1.0/${toEntityTypeUrlSegment(entity.type)}/${entity.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
68
|
+
};
|
|
40
69
|
export const getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT = (recommendationPayload, lineIds) => {
|
|
41
70
|
if (recommendationPayload.length === 0) {
|
|
42
71
|
return undefined;
|
|
@@ -33,6 +33,31 @@ const recommendation = createSlice({
|
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
+
// Targeted recommendations fetch fired when the user changes the
|
|
37
|
+
// payee/customer on a single transaction line (or the JE sibling set
|
|
38
|
+
// for that change). Routed by `fetchEntityRecommendationsForLineUpdateEpic`
|
|
39
|
+
// which uses groupBy + switchMap to keep fetches for distinct targets
|
|
40
|
+
// running in parallel while same-target re-fetches still cancel each
|
|
41
|
+
// other. The flowType discriminator selects the categorization vs
|
|
42
|
+
// detail slice for the per-line In-Progress / Completed / Error state.
|
|
43
|
+
fetchEntityRecommendationsForLineUpdate: {
|
|
44
|
+
reducer(draft, action) {
|
|
45
|
+
const { entity } = action.payload;
|
|
46
|
+
const key = getEntityRecommendationKey(entity.type, entity.id);
|
|
47
|
+
// Unconditional flip to In-Progress; the previous variant only
|
|
48
|
+
// seeded when missing, which left stale fetchStates when a prior
|
|
49
|
+
// fetch had already populated the entity entry.
|
|
50
|
+
draft.recommendationByEntity[key] = {
|
|
51
|
+
...(draft.recommendationByEntity[key] ??
|
|
52
|
+
initialEntityRecommendationState),
|
|
53
|
+
fetchState: 'In-Progress',
|
|
54
|
+
error: undefined,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
prepare(args) {
|
|
58
|
+
return { payload: args };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
36
61
|
fetchRecommendationByEntityName: {
|
|
37
62
|
reducer(draft, action) {
|
|
38
63
|
const { entityName, entityType } = action.payload;
|
|
@@ -111,7 +136,7 @@ const recommendation = createSlice({
|
|
|
111
136
|
},
|
|
112
137
|
},
|
|
113
138
|
});
|
|
114
|
-
export const { fetchEntityRecommendationsByTransactionId, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, clearRecommendation, } = recommendation.actions;
|
|
139
|
+
export const { fetchEntityRecommendationsByTransactionId, fetchEntityRecommendationsForLineUpdate, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, clearRecommendation, } = recommendation.actions;
|
|
115
140
|
export default recommendation.reducer;
|
|
116
141
|
const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
|
|
117
142
|
const key = getEntityRecommendationKey(entityType, entityId);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { mapCurrencyPayloadToCurrency } from '../../../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
3
|
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
4
|
+
import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
|
|
4
5
|
import { initialCashbackAnalytics, } from './cashbackDetailState';
|
|
5
6
|
export const initialState = {
|
|
6
7
|
fetchState: 'Not-Started',
|
|
@@ -27,10 +28,10 @@ const cashbackDetail = createSlice({
|
|
|
27
28
|
name: 'cashbackDetail',
|
|
28
29
|
initialState,
|
|
29
30
|
reducers: {
|
|
30
|
-
fetchCashbackDetail(draft) {
|
|
31
|
+
fetchCashbackDetail: createCacheOverrideFetchReducer((draft) => {
|
|
31
32
|
draft.fetchState = 'In-Progress';
|
|
32
33
|
draft.error = undefined;
|
|
33
|
-
},
|
|
34
|
+
}),
|
|
34
35
|
updateCashbackDetail(draft, action) {
|
|
35
36
|
draft.cashbackByPeriod = toCashbackByPeriod(action.payload);
|
|
36
37
|
draft.cashbackSummary = toCashbackSummary(action.payload);
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js
CHANGED
|
@@ -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 { toCreditLimitFrequencyCodeType } from '../../../../entity/chargeCard/chargeCard';
|
|
4
5
|
import { toCreditTerm, toRePaymentInfo, } from './chargeCardConfigPayload';
|
|
5
6
|
export const initialState = {
|
|
@@ -30,10 +31,10 @@ const chargeCardConfig = createSlice({
|
|
|
30
31
|
name: 'chargeCardConfig',
|
|
31
32
|
initialState,
|
|
32
33
|
reducers: {
|
|
33
|
-
fetchChargeCardConfig(draft) {
|
|
34
|
+
fetchChargeCardConfig: createCacheOverrideFetchReducer((draft) => {
|
|
34
35
|
draft.fetchState = 'In-Progress';
|
|
35
36
|
draft.error = undefined;
|
|
36
|
-
},
|
|
37
|
+
}),
|
|
37
38
|
updateChargeCardConfig(draft, action) {
|
|
38
39
|
const { payload } = action;
|
|
39
40
|
draft.creditLimitFrequency =
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js
CHANGED
|
@@ -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:
|
|
74
|
-
|
|
77
|
+
fetchState: cacheOverride
|
|
78
|
+
? existingCardDetail.transactionList.fetchState
|
|
79
|
+
: 'In-Progress',
|
|
80
|
+
error: cacheOverride
|
|
81
|
+
? existingCardDetail.transactionList.error
|
|
82
|
+
: undefined,
|
|
75
83
|
uiState: {
|
|
76
|
-
...
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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;
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js
CHANGED
|
@@ -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:
|
|
22
|
-
fetchState:
|
|
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',
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js
CHANGED
|
@@ -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) => ({
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
},
|
|
@@ -8,6 +8,8 @@ import { getActualPaymentDate } from './helpers';
|
|
|
8
8
|
import { getApproversOrRejectors as getApproversOrRejectorsForReimbursement, } from './reimbursement/remiListView/remiListSelector';
|
|
9
9
|
import { ALL_REMI_TABS, getRemiListKey, } from './reimbursement/remiListView/remiListState';
|
|
10
10
|
//filters items against filter values representing a range. ex: date (from-to), amount(1k<-->5k)
|
|
11
|
+
// Spend Management uses only equal/not_equal — TC amount operators
|
|
12
|
+
// (inBetween, lessThan, greaterThan) live in the TC filter pipeline.
|
|
11
13
|
const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
|
|
12
14
|
let doesItemFallInValueRange = false;
|
|
13
15
|
const filterField = currentFilter.field;
|
|
@@ -41,7 +43,7 @@ const filterItemOnCategoriesWithSingleValue = (categoryValue, currentFilter, ran
|
|
|
41
43
|
return filterItemOnRangeCategoryType(categoryValue, currentFilter);
|
|
42
44
|
}
|
|
43
45
|
// if filter category is not rangeType
|
|
44
|
-
if (currentFilter.matchingOperator === '
|
|
46
|
+
if (currentFilter.matchingOperator === 'not_equal') {
|
|
45
47
|
return currentFilter.values.indexOf(categoryValue.toString()) === -1;
|
|
46
48
|
}
|
|
47
49
|
return currentFilter.values.indexOf(categoryValue.toString()) > -1;
|
|
@@ -115,7 +117,7 @@ export const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredIt
|
|
|
115
117
|
? getCategoryValueForTaskList(key, item)
|
|
116
118
|
: getCategoryValueForPaymentHistory(key, item);
|
|
117
119
|
if (categoryValue == null) {
|
|
118
|
-
if (currentFilter.matchingOperator === '
|
|
120
|
+
if (currentFilter.matchingOperator === 'not_equal') {
|
|
119
121
|
return true;
|
|
120
122
|
}
|
|
121
123
|
return false;
|
|
@@ -208,7 +208,7 @@ const applyAdvancedFiltersOnCompaniesList = (allCompanies, filters, filteredComp
|
|
|
208
208
|
const key = currentFilter.field;
|
|
209
209
|
const categoryValue = getCategoryValueForCompany(key, company);
|
|
210
210
|
if (categoryValue == null) {
|
|
211
|
-
if (currentFilter.matchingOperator === '
|
|
211
|
+
if (currentFilter.matchingOperator === 'not_equal') {
|
|
212
212
|
return true;
|
|
213
213
|
}
|
|
214
214
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter,
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
4
|
import { mapCannedResponsePayloadToCannedResponse, } from '../cannedResponsesPayload';
|
|
5
5
|
import { fetchCannedResponses, updateCannedResponses, updateCannedResponsesFetchStatus, } from '../cannedResponsesReducer';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter,
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
4
|
import { fetchCannedResponses, saveCannedResponse, saveCannedResponseFailure, saveCannedResponseSuccess, } from '../cannedResponsesReducer';
|
|
5
5
|
export const saveCannedResponseEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveCannedResponse.match), switchMap((action) => {
|
|
@@ -4,7 +4,7 @@ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
|
4
4
|
import { updateTasks } from '../../../../entity/task/taskReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
6
|
import { fetchTaskList, removeTaskFromList, } from '../../taskListView/taskListReducer';
|
|
7
|
-
import { snoozeTaskSuccessOrFailure, unsnoozeTask
|
|
7
|
+
import { snoozeTaskSuccessOrFailure, unsnoozeTask } from '../taskDetailReducer';
|
|
8
8
|
export const unsnoozeTaskEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(unsnoozeTask.match), mergeMap((action) => handleUnsnoozeTask(action.payload.taskId, zeniAPI)));
|
|
9
9
|
const handleUnsnoozeTask = (taskId, zeniAPI) => {
|
|
10
10
|
const unsnoozeTaskApi$ = zeniAPI.deleteAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${taskId}/snooze`);
|