@zeniai/client-epic-state 4.11.3 → 4.11.4
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/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailState.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +2 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +5 -3
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.d.ts +4 -3
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +13 -6
- package/package.json +1 -1
|
@@ -19,6 +19,9 @@ exports.initialState = {
|
|
|
19
19
|
cashbackAvailable: { amount: 0, currencyCode: 'USD', currencySymbol: '$' },
|
|
20
20
|
},
|
|
21
21
|
insightId: '',
|
|
22
|
+
hasValidState() {
|
|
23
|
+
return this.fetchState == 'Completed';
|
|
24
|
+
},
|
|
22
25
|
};
|
|
23
26
|
const cashbackDetail = (0, toolkit_1.createSlice)({
|
|
24
27
|
name: 'cashbackDetail',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Amount } from '../../../../commonStateTypes/amount';
|
|
2
|
-
import {
|
|
2
|
+
import { ID, FetchedState } from '../../../../commonStateTypes/common';
|
|
3
3
|
import { SortOrder } from '../../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
4
|
-
export interface CashbackDetailState extends
|
|
4
|
+
export interface CashbackDetailState extends FetchedState {
|
|
5
5
|
uiState: CashbackDetailUIState;
|
|
6
6
|
cashbackByPeriod: CashbackPeriod[];
|
|
7
7
|
cashbackSummary: {
|
|
@@ -3,8 +3,8 @@ import { ChargeCardListPayload, CreditAccountPayload } from './chargeCardListPay
|
|
|
3
3
|
import { ChargeCardListState, ChargeCardListUIState, ChargeCardLocalData, CreditAccount } from './chargeCardList';
|
|
4
4
|
import { FetchState } from '../../../../commonStateTypes/common';
|
|
5
5
|
export declare const initialState: ChargeCardListState;
|
|
6
|
-
export declare const fetchChargeCardListPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[
|
|
7
|
-
|
|
6
|
+
export declare const fetchChargeCardListPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[doFetchCreditAccountsAndCashback: boolean, cacheOverride?: any], {
|
|
7
|
+
doFetchCreditAccountsAndCashback: boolean;
|
|
8
8
|
cacheOverride: any;
|
|
9
9
|
}, string, never, never>, fetchCreditAccount: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateCreditAccount: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreditAccountPayload[], string>, updateCreditAccountFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, string>, fetchChargeCardList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateChargeCardList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
10
10
|
chargeCardListPayload: ChargeCardListPayload;
|
|
@@ -29,9 +29,9 @@ const chargeCardList = (0, toolkit_1.createSlice)({
|
|
|
29
29
|
reducer() {
|
|
30
30
|
//do nothing
|
|
31
31
|
},
|
|
32
|
-
prepare(
|
|
32
|
+
prepare(doFetchCreditAccountsAndCashback, cacheOverride = false) {
|
|
33
33
|
return {
|
|
34
|
-
payload: {
|
|
34
|
+
payload: { doFetchCreditAccountsAndCashback, cacheOverride },
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
37
|
},
|
|
@@ -17,6 +17,7 @@ export interface ChargeCardWithUser extends ChargeCard {
|
|
|
17
17
|
address?: Address;
|
|
18
18
|
}
|
|
19
19
|
export interface ChargeCardListSelectorView extends SelectorView {
|
|
20
|
+
totalCashback: Amount;
|
|
20
21
|
cards: ChargeCardWithUser[];
|
|
21
22
|
creditAccount: CreditAccount;
|
|
22
23
|
chargeCardConfig: ChargeCardConfigState;
|
|
@@ -28,4 +29,4 @@ export interface ChargeCardListSelectorView extends SelectorView {
|
|
|
28
29
|
searchText: string;
|
|
29
30
|
unAssignedCredits?: Amount;
|
|
30
31
|
}
|
|
31
|
-
export declare const getChargeCardListView: (state: RootState,
|
|
32
|
+
export declare const getChargeCardListView: (state: RootState, includeCreditAccountAndCashbackInfo: boolean) => ChargeCardListSelectorView;
|
|
@@ -13,8 +13,8 @@ const classSelector_1 = require("../../../../entity/class/classSelector");
|
|
|
13
13
|
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
14
14
|
const userRoleSelector_1 = require("../../../../entity/userRole/userRoleSelector");
|
|
15
15
|
const userListViewSelector_1 = require("../../../userListView/userListViewSelector");
|
|
16
|
-
const getChargeCardListView = (state,
|
|
17
|
-
const { addressState, chargeCardListState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, classListState, } = state;
|
|
16
|
+
const getChargeCardListView = (state, includeCreditAccountAndCashbackInfo) => {
|
|
17
|
+
const { addressState, chargeCardListState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, classListState, cashbackDetailState, } = state;
|
|
18
18
|
const searchText = chargeCardListState.searchText.toLowerCase();
|
|
19
19
|
const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds)
|
|
20
20
|
.map((chargeCard) => {
|
|
@@ -56,11 +56,12 @@ const getChargeCardListView = (state, includeCreditAccount) => {
|
|
|
56
56
|
}, sortOrder);
|
|
57
57
|
const userListSelectorView = (0, userListViewSelector_1.getUserList)(state, 'cardHolderCandidate');
|
|
58
58
|
const userList = userListSelectorView.users;
|
|
59
|
-
const fetchState =
|
|
59
|
+
const fetchState = includeCreditAccountAndCashbackInfo === true
|
|
60
60
|
? (0, reduceFetchState_1.reduceFetchState)([
|
|
61
61
|
chargeCardListState,
|
|
62
62
|
chargeCardListState.creditAccount,
|
|
63
63
|
chargeCardConfigState,
|
|
64
|
+
cashbackDetailState,
|
|
64
65
|
]).fetchState
|
|
65
66
|
: (0, reduceFetchState_1.reduceFetchState)([chargeCardListState, chargeCardConfigState])
|
|
66
67
|
.fetchState;
|
|
@@ -76,6 +77,7 @@ const getChargeCardListView = (state, includeCreditAccount) => {
|
|
|
76
77
|
return {
|
|
77
78
|
fetchState,
|
|
78
79
|
error: chargeCardListState.error,
|
|
80
|
+
totalCashback: cashbackDetailState.cashbackSummary.cashbackEarned,
|
|
79
81
|
cards: cardsInOrder,
|
|
80
82
|
unAssignedCredits: chargeCardListState.unAssignedCredits,
|
|
81
83
|
creditAccount: chargeCardListState.creditAccount,
|
package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../../reducer';
|
|
4
|
-
import { fetchChargeCardConfig } from '../chargeCardConfig/chargeCardConfigReducer';
|
|
5
|
-
import { fetchChargeCardListPage, fetchCreditAccount, fetchChargeCardList } from './chargeCardListReducer';
|
|
6
4
|
import { fetchUserListByType } from '../../../userListView/userListViewReducer';
|
|
7
5
|
import { fetchClassList } from '../../../classList/classListReducer';
|
|
8
|
-
|
|
6
|
+
import { fetchChargeCardConfig } from '../chargeCardConfig/chargeCardConfigReducer';
|
|
7
|
+
import { fetchCashbackDetail } from '../cashbackDetail/cashbackDetailReducer';
|
|
8
|
+
import { fetchChargeCardListPage, fetchCreditAccount, fetchChargeCardList } from './chargeCardListReducer';
|
|
9
|
+
export declare type ActionType = ReturnType<typeof fetchChargeCardListPage> | ReturnType<typeof fetchCreditAccount> | ReturnType<typeof fetchChargeCardList> | ReturnType<typeof fetchChargeCardConfig> | ReturnType<typeof fetchUserListByType> | ReturnType<typeof fetchCashbackDetail> | ReturnType<typeof fetchClassList>;
|
|
9
10
|
export declare const fetchChargeCardListPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchChargeCardListPageEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const chargeCardConfigReducer_1 = require("../chargeCardConfig/chargeCardConfigReducer");
|
|
7
|
-
const chargeCardListReducer_1 = require("./chargeCardListReducer");
|
|
8
6
|
const userListViewReducer_1 = require("../../../userListView/userListViewReducer");
|
|
9
7
|
const classListReducer_1 = require("../../../classList/classListReducer");
|
|
8
|
+
const chargeCardConfigReducer_1 = require("../chargeCardConfig/chargeCardConfigReducer");
|
|
9
|
+
const cashbackDetailReducer_1 = require("../cashbackDetail/cashbackDetailReducer");
|
|
10
|
+
const chargeCardListReducer_1 = require("./chargeCardListReducer");
|
|
10
11
|
const fetchChargeCardListPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(chargeCardListReducer_1.fetchChargeCardListPage.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
-
const {
|
|
12
|
+
const { doFetchCreditAccountsAndCashback, cacheOverride } = action.payload;
|
|
12
13
|
const chargeCardListPageAction = [];
|
|
13
14
|
const state = state$.value;
|
|
15
|
+
const cashbackDetailState = state.cashbackDetailState;
|
|
14
16
|
if (cacheOverride === true) {
|
|
15
|
-
if (
|
|
16
|
-
chargeCardListPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
|
|
17
|
+
if (doFetchCreditAccountsAndCashback === true) {
|
|
18
|
+
chargeCardListPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)(), (0, cashbackDetailReducer_1.fetchCashbackDetail)());
|
|
17
19
|
}
|
|
18
20
|
chargeCardListPageAction.push((0, chargeCardListReducer_1.fetchChargeCardList)());
|
|
19
21
|
chargeCardListPageAction.push((0, chargeCardConfigReducer_1.fetchChargeCardConfig)());
|
|
@@ -22,11 +24,16 @@ const fetchChargeCardListPageEpic = (actions$, state$) => actions$.pipe((0, oper
|
|
|
22
24
|
}
|
|
23
25
|
else {
|
|
24
26
|
const chargeCardList = state.chargeCardListState;
|
|
25
|
-
if (
|
|
27
|
+
if (doFetchCreditAccountsAndCashback === true &&
|
|
26
28
|
chargeCardList.creditAccount.fetchState !== 'Completed' &&
|
|
27
29
|
chargeCardList.creditAccount.fetchState !== 'In-Progress') {
|
|
28
30
|
chargeCardListPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
|
|
29
31
|
}
|
|
32
|
+
if (doFetchCreditAccountsAndCashback &&
|
|
33
|
+
cashbackDetailState.fetchState !== 'In-Progress' &&
|
|
34
|
+
cashbackDetailState.hasValidState() === false) {
|
|
35
|
+
chargeCardListPageAction.push((0, cashbackDetailReducer_1.fetchCashbackDetail)());
|
|
36
|
+
}
|
|
30
37
|
if (chargeCardList.fetchState !== 'In-Progress' &&
|
|
31
38
|
chargeCardList.hasValidState() === false) {
|
|
32
39
|
chargeCardListPageAction.push((0, chargeCardListReducer_1.fetchChargeCardList)());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.4",
|
|
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",
|