@zeniai/client-epic-state 5.0.65 → 5.0.66-betaAK1
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/amount.d.ts +1 -0
- package/lib/commonStateTypes/amount.js +3 -1
- package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +17 -0
- package/lib/commonStateTypes/cacheOverrideFetchReducer.js +20 -0
- package/lib/commonStateTypes/pusherActions.d.ts +11 -0
- package/lib/commonStateTypes/pusherActions.js +6 -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/upcomingPaymentEvent/upcomingPaymentEventPayload.d.ts +11 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +23 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.d.ts +6 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +31 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.d.ts +4 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +16 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.d.ts +13 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +2 -0
- package/lib/epic.d.ts +4 -1
- package/lib/epic.js +4 -1
- package/lib/esm/commonStateTypes/amount.js +1 -0
- package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
- package/lib/esm/commonStateTypes/pusherActions.js +3 -0
- package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
- package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +19 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +27 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +11 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +1 -0
- package/lib/esm/epic.js +4 -1
- package/lib/esm/index.js +7 -2
- package/lib/esm/reducer.js +6 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +1 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +88 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +93 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +14 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +6 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +35 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +22 -0
- 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 +28 -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/index.d.ts +9 -3
- package/lib/index.js +27 -11
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.d.ts +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +2 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +92 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +98 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.d.ts +21 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +17 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.d.ts +5 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.d.ts +8 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +39 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.d.ts +8 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +26 -0
- 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 +29 -10
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
- 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/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
import { initialCashManagementBannerState, initialUpcomingPaymentEventsListState, } from './cashManagementOverviewState';
|
|
3
|
+
export const initialState = {
|
|
4
|
+
banner: initialCashManagementBannerState,
|
|
5
|
+
upcomingPaymentEvents: initialUpcomingPaymentEventsListState,
|
|
6
|
+
fetchState: 'Not-Started',
|
|
7
|
+
error: undefined,
|
|
8
|
+
hasValidState() {
|
|
9
|
+
return this.fetchState == 'Completed';
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const cashManagementOverview = createSlice({
|
|
13
|
+
name: 'cashManagementOverview',
|
|
14
|
+
initialState,
|
|
15
|
+
reducers: {
|
|
16
|
+
fetchCashManagementOverviewPage: {
|
|
17
|
+
reducer(
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
+
_draft,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
_action) {
|
|
22
|
+
// do nothing - the corresponding epic listens to this action and fans out
|
|
23
|
+
},
|
|
24
|
+
prepare(cacheOverride) {
|
|
25
|
+
return { payload: { cacheOverride } };
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
fetchUpcomingPaymentEvents(draft) {
|
|
29
|
+
draft.upcomingPaymentEvents = {
|
|
30
|
+
...draft.upcomingPaymentEvents,
|
|
31
|
+
fetchState: 'In-Progress',
|
|
32
|
+
error: undefined,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
updateUpcomingPaymentEventsList(draft, action) {
|
|
36
|
+
const { data } = action.payload;
|
|
37
|
+
const eventIds = [];
|
|
38
|
+
data.events.forEach((payload) => {
|
|
39
|
+
if (payload.id != null) {
|
|
40
|
+
eventIds.push(payload.id);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
draft.upcomingPaymentEvents = {
|
|
44
|
+
fetchState: 'Completed',
|
|
45
|
+
error: undefined,
|
|
46
|
+
billStages: (data.bill_stages ?? []),
|
|
47
|
+
eventIds,
|
|
48
|
+
horizonDays: data.horizon_days,
|
|
49
|
+
reimbursementStages: (data.reimbursement_stages ??
|
|
50
|
+
[]),
|
|
51
|
+
tenantNamespace: data.tenant_namespace,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
updateUpcomingPaymentEventsListFetchStatus(draft, action) {
|
|
55
|
+
draft.upcomingPaymentEvents = {
|
|
56
|
+
...draft.upcomingPaymentEvents,
|
|
57
|
+
fetchState: action.payload.fetchState,
|
|
58
|
+
error: action.payload.error,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
fetchCashManagementBanner(draft) {
|
|
62
|
+
draft.banner = {
|
|
63
|
+
...initialCashManagementBannerState,
|
|
64
|
+
fetchState: 'In-Progress',
|
|
65
|
+
error: undefined,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
updateCashManagementBanner(draft, action) {
|
|
69
|
+
draft.banner = {
|
|
70
|
+
fetchState: 'Completed',
|
|
71
|
+
error: undefined,
|
|
72
|
+
data: action.payload.data,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
updateCashManagementBannerFetchStatus(draft, action) {
|
|
76
|
+
draft.banner = {
|
|
77
|
+
...draft.banner,
|
|
78
|
+
fetchState: action.payload.fetchState,
|
|
79
|
+
error: action.payload.error,
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
clearCashManagementOverview(draft) {
|
|
83
|
+
Object.assign(draft, initialState);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
export const { fetchCashManagementOverviewPage, fetchUpcomingPaymentEvents, updateUpcomingPaymentEventsList, updateUpcomingPaymentEventsListFetchStatus, fetchCashManagementBanner, updateCashManagementBanner, updateCashManagementBannerFetchStatus, clearCashManagementOverview, } = cashManagementOverview.actions;
|
|
88
|
+
export default cashManagementOverview.reducer;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { zeroAmount } from '../../../../commonStateTypes/amount';
|
|
2
|
+
import { reduceAllFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
3
|
+
import { getUpcomingPaymentEventsByIds } from '../../../../entity/upcomingPaymentEvent/upcomingPaymentEventSelector';
|
|
4
|
+
export const getCashManagementOverviewBanner = (state) => {
|
|
5
|
+
const { banner } = state.cashManagementOverviewState;
|
|
6
|
+
return {
|
|
7
|
+
fetchState: banner.fetchState,
|
|
8
|
+
error: banner.error,
|
|
9
|
+
data: banner.data,
|
|
10
|
+
version: 0,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const getCashManagementOverview = (state) => {
|
|
14
|
+
const { cashManagementOverviewState, depositAccountListState, depositAccountState, paymentAccountListState, paymentAccountState, treasuryDetailState, } = state;
|
|
15
|
+
const outflowEventsFetchState = {
|
|
16
|
+
fetchState: cashManagementOverviewState.upcomingPaymentEvents.fetchState,
|
|
17
|
+
error: cashManagementOverviewState.upcomingPaymentEvents.error,
|
|
18
|
+
};
|
|
19
|
+
const bannerFetchState = {
|
|
20
|
+
fetchState: cashManagementOverviewState.banner.fetchState,
|
|
21
|
+
error: cashManagementOverviewState.banner.error,
|
|
22
|
+
};
|
|
23
|
+
const aggregate = reduceAllFetchState([
|
|
24
|
+
{
|
|
25
|
+
fetchState: paymentAccountListState.fetchState,
|
|
26
|
+
error: paymentAccountListState.error,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
fetchState: depositAccountListState.fetchState,
|
|
30
|
+
error: depositAccountListState.error,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
fetchState: treasuryDetailState.fetchState,
|
|
34
|
+
error: treasuryDetailState.error,
|
|
35
|
+
},
|
|
36
|
+
outflowEventsFetchState,
|
|
37
|
+
bannerFetchState,
|
|
38
|
+
]);
|
|
39
|
+
const treasuryBalance = treasuryDetailState.accountSummary?.totalBalance ?? zeroAmount();
|
|
40
|
+
const cashBalance = sumCashBalances(paymentAccountListState.paymentAccountIds, paymentAccountState, depositAccountListState.accountIds, depositAccountState);
|
|
41
|
+
const totalCash = addAmounts(treasuryBalance, cashBalance);
|
|
42
|
+
return {
|
|
43
|
+
bannerFetchState,
|
|
44
|
+
cashBalance,
|
|
45
|
+
horizonDays: cashManagementOverviewState.upcomingPaymentEvents.horizonDays,
|
|
46
|
+
outflowEvents: getUpcomingPaymentEventsByIds(state.upcomingPaymentEventState, cashManagementOverviewState.upcomingPaymentEvents.eventIds),
|
|
47
|
+
outflowEventsFetchState,
|
|
48
|
+
totalCash,
|
|
49
|
+
treasuryBalance,
|
|
50
|
+
fetchState: aggregate.fetchState,
|
|
51
|
+
error: aggregate.error,
|
|
52
|
+
version: 0,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const isZeroAmount = (a) => a.amount === 0 && a.currencyCode === 'USD' && a.currencySymbol === '$';
|
|
56
|
+
/**
|
|
57
|
+
* Adds two Amounts. Currencies must match (the seeded zeroAmount() counts as
|
|
58
|
+
* "no currency yet" and adopts `b`'s currency). Mismatches return `a`
|
|
59
|
+
* unchanged and warn — mixing currencies in a total is a bug, not silent
|
|
60
|
+
* conversion.
|
|
61
|
+
*/
|
|
62
|
+
const addAmounts = (a, b) => {
|
|
63
|
+
if (isZeroAmount(a)) {
|
|
64
|
+
return { ...b };
|
|
65
|
+
}
|
|
66
|
+
if (a.currencyCode !== b.currencyCode ||
|
|
67
|
+
a.currencySymbol !== b.currencySymbol) {
|
|
68
|
+
console.warn(`cashManagementOverview: skipping balance with mismatched currency. Expected ${a.currencyCode} (${a.currencySymbol}), got ${b.currencyCode} (${b.currencySymbol}).`);
|
|
69
|
+
return a;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
amount: a.amount + b.amount,
|
|
73
|
+
currencyCode: a.currencyCode,
|
|
74
|
+
currencySymbol: a.currencySymbol,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const sumCashBalances = (paymentAccountIds, paymentAccountState, depositAccountIds, depositAccountState) => {
|
|
78
|
+
let total = zeroAmount();
|
|
79
|
+
paymentAccountIds.forEach((id) => {
|
|
80
|
+
const balance = paymentAccountState.paymentAccountByID[id]?.balances
|
|
81
|
+
?.available;
|
|
82
|
+
if (balance != null) {
|
|
83
|
+
total = addAmounts(total, balance);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
depositAccountIds.forEach((id) => {
|
|
87
|
+
const balance = depositAccountState.depositAccountByID[id]?.accountBalance?.available;
|
|
88
|
+
if (balance != null) {
|
|
89
|
+
total = addAmounts(total, balance);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return total;
|
|
93
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const initialCashManagementBannerState = {
|
|
2
|
+
fetchState: 'Not-Started',
|
|
3
|
+
error: undefined,
|
|
4
|
+
data: undefined,
|
|
5
|
+
};
|
|
6
|
+
export const initialUpcomingPaymentEventsListState = {
|
|
7
|
+
fetchState: 'Not-Started',
|
|
8
|
+
error: undefined,
|
|
9
|
+
billStages: [],
|
|
10
|
+
eventIds: [],
|
|
11
|
+
horizonDays: 0,
|
|
12
|
+
reimbursementStages: [],
|
|
13
|
+
tenantNamespace: undefined,
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EMPTY } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchCashManagementBanner, } from '../cashManagementOverviewReducer';
|
|
4
|
+
// TODO: replace EMPTY with an actual API call once the banner endpoint is finalized.
|
|
5
|
+
// Figma: https://www.figma.com/design/FUg2pv7edRAidx9X56VnZT/Cash-Management?node-id=2265-63443
|
|
6
|
+
export const fetchCashManagementBannerEpic = (actions$) => actions$.pipe(filter(fetchCashManagementBanner.match), mergeMap(() => EMPTY));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { concat, from } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchTreasuryOverviewDetail } from '../../../treasury/treasuryList/treasuryDetailReducer';
|
|
4
|
+
import { fetchZeniAccountList } from '../../../zeniAccounts/zeniAccountList/zeniAccountListReducer';
|
|
5
|
+
import { fetchCashManagementBanner, fetchCashManagementOverviewPage, fetchUpcomingPaymentEvents, } from '../cashManagementOverviewReducer';
|
|
6
|
+
export const fetchCashManagementOverviewPageEpic = (actions$, state$) => actions$.pipe(filter(fetchCashManagementOverviewPage.match), mergeMap((action) => {
|
|
7
|
+
const { cacheOverride } = action.payload;
|
|
8
|
+
const state = state$.value;
|
|
9
|
+
const pageActions = [];
|
|
10
|
+
if (cacheOverride === true) {
|
|
11
|
+
pageActions.push(fetchTreasuryOverviewDetail(true));
|
|
12
|
+
pageActions.push(fetchZeniAccountList(true));
|
|
13
|
+
pageActions.push(fetchUpcomingPaymentEvents());
|
|
14
|
+
pageActions.push(fetchCashManagementBanner());
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const treasuryDetailState = state.treasuryDetailState;
|
|
18
|
+
if (treasuryDetailState.hasValidState() === false &&
|
|
19
|
+
treasuryDetailState.fetchState !== 'In-Progress') {
|
|
20
|
+
pageActions.push(fetchTreasuryOverviewDetail(false));
|
|
21
|
+
}
|
|
22
|
+
pageActions.push(fetchZeniAccountList(false));
|
|
23
|
+
const upcomingEvents = state.cashManagementOverviewState.upcomingPaymentEvents;
|
|
24
|
+
if (upcomingEvents.fetchState !== 'Completed' &&
|
|
25
|
+
upcomingEvents.fetchState !== 'In-Progress') {
|
|
26
|
+
pageActions.push(fetchUpcomingPaymentEvents());
|
|
27
|
+
}
|
|
28
|
+
const banner = state.cashManagementOverviewState.banner;
|
|
29
|
+
if (banner.fetchState !== 'Completed' &&
|
|
30
|
+
banner.fetchState !== 'In-Progress') {
|
|
31
|
+
pageActions.push(fetchCashManagementBanner());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return concat(from(pageActions));
|
|
35
|
+
}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
|
+
import { updateUpcomingPaymentEvents } from '../../../../../entity/upcomingPaymentEvent/upcomingPaymentEventReducer';
|
|
5
|
+
import { fetchUpcomingPaymentEvents, updateUpcomingPaymentEventsList, updateUpcomingPaymentEventsListFetchStatus, } from '../cashManagementOverviewReducer';
|
|
6
|
+
export const fetchUpcomingPaymentEventsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchUpcomingPaymentEvents.match), switchMap(() => zeniAPI
|
|
7
|
+
.getJSON(
|
|
8
|
+
// TODO: drop /rajat/ once the prod endpoint lands.
|
|
9
|
+
`${zeniAPI.apiEndPoints.spendManagementMicroServiceBaseUrl}/rajat/1.0/upcoming-payment-events`)
|
|
10
|
+
.pipe(mergeMap((response) => {
|
|
11
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
12
|
+
return of(updateUpcomingPaymentEvents(response.data.events), updateUpcomingPaymentEventsList({ data: response.data }));
|
|
13
|
+
}
|
|
14
|
+
return of(updateUpcomingPaymentEventsListFetchStatus({
|
|
15
|
+
fetchState: 'Error',
|
|
16
|
+
error: response.status,
|
|
17
|
+
}));
|
|
18
|
+
}), catchError((error) => of(updateUpcomingPaymentEventsListFetchStatus({
|
|
19
|
+
fetchState: 'Error',
|
|
20
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch upcoming payment events REST API call errored out' +
|
|
21
|
+
JSON.stringify(error)),
|
|
22
|
+
}))))));
|
|
@@ -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
|
@@ -2,6 +2,7 @@ import { createSlice } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { mapSortOrderPayloadToSortOrder, } from '../../../../commonPayloadTypes/sortOrderPayload';
|
|
3
3
|
import { toAttachment, } from '../../../../entity/transaction/payloadTypes/attachmentPayload';
|
|
4
4
|
import { emptyChargeCardDetail, mapChargeCardTransactionStatisticsPayloadToChargeCardTransactionStatistics, toChargeCardTransactionSortKeyType, } from './chargeCardDetail';
|
|
5
|
+
import { addChargeCardTransactionFromPusher, addDeclinedChargeCardTransactionFromPusher, } from '../../../../commonStateTypes/pusherActions';
|
|
5
6
|
export const initialState = {
|
|
6
7
|
detailById: {},
|
|
7
8
|
recurringExpensesByChargeCardId: {},
|
|
@@ -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,20 @@ 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
|
|
163
|
+
? toAmount(v, currencyCode, currencySymbol)
|
|
164
|
+
: undefined;
|
|
165
|
+
draft.creditAccount.available =
|
|
166
|
+
amt(action.payload.available) ?? draft.creditAccount.available;
|
|
167
|
+
draft.creditAccount.balance =
|
|
168
|
+
amt(action.payload.balance) ?? draft.creditAccount.balance;
|
|
169
|
+
draft.creditAccount.hold =
|
|
170
|
+
amt(action.payload.hold) ?? draft.creditAccount.hold;
|
|
171
|
+
draft.creditAccount.cashback =
|
|
172
|
+
amt(action.payload.cashback) ?? draft.creditAccount.cashback;
|
|
173
|
+
},
|
|
155
174
|
clearChargeCardList(draft) {
|
|
156
175
|
Object.assign(draft, initialState);
|
|
157
176
|
},
|
|
@@ -307,7 +326,7 @@ const chargeCardList = createSlice({
|
|
|
307
326
|
},
|
|
308
327
|
},
|
|
309
328
|
});
|
|
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;
|
|
329
|
+
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
330
|
export default chargeCardList.reducer;
|
|
312
331
|
// helper
|
|
313
332
|
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' &&
|