@zeniai/client-epic-state 4.14.36 → 4.14.38
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/entity/chargeCard/chargeCardReducer.d.ts +4 -1
- package/lib/entity/chargeCard/chargeCardReducer.js +23 -5
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +2 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +8 -6
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +7 -5
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { UpdateType } from '../../commonStateTypes/common';
|
|
1
2
|
import { ChargeCardState } from './chargeCard';
|
|
2
3
|
import { ChargeCardPayload } from './chargeCardPayload';
|
|
3
4
|
export declare const initialState: ChargeCardState;
|
|
4
|
-
export declare const updateChargeCards: import("@reduxjs/toolkit").
|
|
5
|
+
export declare const updateChargeCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCards: ChargeCardPayload[], updateType?: UpdateType | undefined], ChargeCardPayload[], string, never, {
|
|
6
|
+
updateType: UpdateType;
|
|
7
|
+
}>, updateChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardPayload, string>, removeChargeCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, clearAllChargeCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
5
8
|
declare const _default: import("@reduxjs/toolkit").Reducer<ChargeCardState, import("@reduxjs/toolkit").AnyAction>;
|
|
6
9
|
export default _default;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
var _a;
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.clearAllChargeCards = exports.removeChargeCard = exports.updateChargeCard = exports.updateChargeCards = exports.initialState = void 0;
|
|
5
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const assignWith_1 = __importDefault(require("lodash/assignWith"));
|
|
6
10
|
const chargeCardPayload_1 = require("./chargeCardPayload");
|
|
7
11
|
exports.initialState = {
|
|
8
12
|
chargeCardByID: {},
|
|
@@ -11,11 +15,25 @@ const chargeCard = (0, toolkit_1.createSlice)({
|
|
|
11
15
|
name: 'chargeCard',
|
|
12
16
|
initialState: exports.initialState,
|
|
13
17
|
reducers: {
|
|
14
|
-
updateChargeCards
|
|
15
|
-
action
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
updateChargeCards: {
|
|
19
|
+
reducer(draft, action) {
|
|
20
|
+
action.payload.forEach((chargeCardPayload) => {
|
|
21
|
+
const latestChargeCard = (0, chargeCardPayload_1.mapChargeCardPayloadToChargeCard)(chargeCardPayload);
|
|
22
|
+
if (latestChargeCard.id in draft.chargeCardByID &&
|
|
23
|
+
action.meta.updateType === 'merge') {
|
|
24
|
+
(0, assignWith_1.default)(draft.chargeCardByID[latestChargeCard.id], latestChargeCard, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
draft.chargeCardByID = Object.assign(Object.assign({}, draft.chargeCardByID), { [latestChargeCard.id]: latestChargeCard });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
prepare(chargeCards, updateType = 'merge') {
|
|
32
|
+
return {
|
|
33
|
+
payload: chargeCards,
|
|
34
|
+
meta: { updateType },
|
|
35
|
+
};
|
|
36
|
+
},
|
|
19
37
|
},
|
|
20
38
|
updateChargeCard(draft, action) {
|
|
21
39
|
const latestChargeCard = (0, chargeCardPayload_1.mapChargeCardPayloadToChargeCard)(action.payload);
|
|
@@ -6,8 +6,9 @@ import { ZeniAPIStatus } from '../../../../responsePayload';
|
|
|
6
6
|
import { ChargeCardDetailState, ChargeCardDetailUiState } from './chargeCardDetail';
|
|
7
7
|
import { ChargeCardTransactionListPayload } from './chargeCardDetailPayload';
|
|
8
8
|
export declare const initialState: ChargeCardDetailState;
|
|
9
|
-
export declare const fetchChargeCardDetailPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, cacheOverride?: any], {
|
|
9
|
+
export declare const fetchChargeCardDetailPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, doFetchCreditAccounts: boolean, cacheOverride?: any], {
|
|
10
10
|
chargeCardId: string;
|
|
11
|
+
doFetchCreditAccounts: boolean;
|
|
11
12
|
cacheOverride: any;
|
|
12
13
|
}, string, never, never>, fetchChargeCardDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, cacheOverride?: any], {
|
|
13
14
|
chargeCardId: string;
|
|
@@ -17,9 +17,9 @@ const chargeCardDetail = (0, toolkit_1.createSlice)({
|
|
|
17
17
|
reducer() {
|
|
18
18
|
//do nothing
|
|
19
19
|
},
|
|
20
|
-
prepare(chargeCardId, cacheOverride = false) {
|
|
20
|
+
prepare(chargeCardId, doFetchCreditAccounts, cacheOverride = false) {
|
|
21
21
|
return {
|
|
22
|
-
payload: { chargeCardId, cacheOverride },
|
|
22
|
+
payload: { chargeCardId, doFetchCreditAccounts, cacheOverride },
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
25
|
},
|
|
@@ -24,7 +24,7 @@ export interface ChargeCardDetailSelectorView extends SelectorView {
|
|
|
24
24
|
updateChargeCardLimitFetchState: FetchStateAndError;
|
|
25
25
|
chargeCard?: ChargeCardWithUser;
|
|
26
26
|
}
|
|
27
|
-
export declare const getChargeCardDetailView: (state: RootState, chargeCardId: ID) => ChargeCardDetailSelectorView;
|
|
27
|
+
export declare const getChargeCardDetailView: (state: RootState, chargeCardId: ID, includeCreditAccountInfo: boolean) => ChargeCardDetailSelectorView;
|
|
28
28
|
export interface ChargeCardCVVActivateSelectorView extends SelectorView {
|
|
29
29
|
updatePhysicalChargeCardAttemptFetchState: FetchStateAndError;
|
|
30
30
|
updateStatus: FetchStateAndError;
|
|
@@ -14,7 +14,7 @@ const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
|
14
14
|
const userRoleSelector_1 = require("../../../../entity/userRole/userRoleSelector");
|
|
15
15
|
const twoFactorAuthenticationSelector_1 = require("../../../twoFactorAuthentication/twoFactorAuthenticationSelector");
|
|
16
16
|
const chargeCardDetail_1 = require("./chargeCardDetail");
|
|
17
|
-
const getChargeCardDetailView = (state, chargeCardId) => {
|
|
17
|
+
const getChargeCardDetailView = (state, chargeCardId, includeCreditAccountInfo) => {
|
|
18
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
19
19
|
const { tenantState, addressState, chargeCardDetailState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, chargeCardTransactionState, chargeCardListState, } = state;
|
|
20
20
|
const twoFactorAuthenticationView = (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationView)(state);
|
|
@@ -34,11 +34,13 @@ const getChargeCardDetailView = (state, chargeCardId) => {
|
|
|
34
34
|
error: undefined,
|
|
35
35
|
};
|
|
36
36
|
if (chargeCardDetail) {
|
|
37
|
-
reducedFetchState =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
reducedFetchState = includeCreditAccountInfo
|
|
38
|
+
? (0, reduceFetchState_1.reduceFetchState)([
|
|
39
|
+
chargeCardDetail,
|
|
40
|
+
chargeCardConfigState,
|
|
41
|
+
chargeCardListState.creditAccount,
|
|
42
|
+
])
|
|
43
|
+
: (0, reduceFetchState_1.reduceFetchState)([chargeCardDetail, chargeCardConfigState]);
|
|
42
44
|
}
|
|
43
45
|
if (chargeCardDetail &&
|
|
44
46
|
chargeCardDetail.fetchState === 'Completed' &&
|
package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js
CHANGED
|
@@ -7,7 +7,7 @@ const chargeCardConfigReducer_1 = require("../chargeCardConfig/chargeCardConfigR
|
|
|
7
7
|
const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
|
|
8
8
|
const chargeCardDetailReducer_1 = require("./chargeCardDetailReducer");
|
|
9
9
|
const fetchChargeCardDetailPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(chargeCardDetailReducer_1.fetchChargeCardDetailPage.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const { chargeCardId, cacheOverride } = action.payload;
|
|
10
|
+
const { chargeCardId, cacheOverride, doFetchCreditAccounts } = action.payload;
|
|
11
11
|
const chargeCardTransactionListAction = [];
|
|
12
12
|
const state = state$.value;
|
|
13
13
|
const exsitingChargeCardDetail = state.chargeCardDetailState.detailById[chargeCardId];
|
|
@@ -22,7 +22,9 @@ const fetchChargeCardDetailPageEpic = (actions$, state$) => actions$.pipe((0, op
|
|
|
22
22
|
//latest transactions need to be fetched hence removing pageToken and pageTokenType
|
|
23
23
|
chargeCardTransactionListAction.push((0, chargeCardDetailReducer_1.fetchChargeCardTransactionList)(chargeCardId, null, null));
|
|
24
24
|
chargeCardTransactionListAction.push((0, chargeCardConfigReducer_1.fetchChargeCardConfig)());
|
|
25
|
-
|
|
25
|
+
if (doFetchCreditAccounts) {
|
|
26
|
+
chargeCardTransactionListAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
28
30
|
const chargeCardDetail = state.chargeCardDetailState.detailById[chargeCardId];
|
|
@@ -43,9 +45,9 @@ const fetchChargeCardDetailPageEpic = (actions$, state$) => actions$.pipe((0, op
|
|
|
43
45
|
chargeCardTransactionListAction.push((0, chargeCardConfigReducer_1.fetchChargeCardConfig)());
|
|
44
46
|
}
|
|
45
47
|
const chargeCardList = state.chargeCardListState;
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (chargeCardList.creditAccount.fetchState !== 'Completed' &&
|
|
49
|
+
chargeCardList.creditAccount.fetchState !== 'In-Progress' &&
|
|
50
|
+
doFetchCreditAccounts) {
|
|
49
51
|
chargeCardTransactionListAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
|
|
50
52
|
}
|
|
51
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.38",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|