@zeniai/client-epic-state 4.17.48 → 4.17.49
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/chargeCard.d.ts +1 -0
- package/lib/entity/chargeCard/chargeCardPayload.d.ts +1 -0
- package/lib/entity/chargeCard/chargeCardPayload.js +10 -9
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.d.ts +32 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.js +14 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.d.ts +28 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +34 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentReducer.d.ts +6 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentReducer.js +41 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentSelector.d.ts +4 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentSelector.js +17 -0
- package/lib/entity/company/companyPayload.d.ts +1 -0
- package/lib/entity/company/companyPayload.js +1 -0
- package/lib/entity/company/companyReducer.d.ts +4 -1
- package/lib/entity/company/companyReducer.js +7 -2
- package/lib/entity/company/companyStateTypes.d.ts +1 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +4 -2
- package/lib/entity/tenant/clearAllEpic.js +4 -0
- package/lib/epic.d.ts +5 -1
- package/lib/epic.js +5 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.js +18 -8
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/view/addressView/__mocks__/json/createCompanyAddressSuccess.json +2 -1
- package/lib/view/addressView/__mocks__/json/createCompanyUserAddressSuccess.json +2 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.d.ts +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.js +4 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailPayload.d.ts +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +9 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +36 -4
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +4 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +16 -9
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +13 -3
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/postChargeCardEmailForLowBalanceToAdminEpic.d.ts +8 -0
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/postChargeCardEmailForLowBalanceToAdminEpic.js +34 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListPayload.d.ts +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +6 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +9 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +7 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +49 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.d.ts +11 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +32 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailState.d.ts +12 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailState.js +2 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentPayload.d.ts +7 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentPayload.js +2 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.d.ts +8 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +24 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +10 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +87 -0
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.d.ts +4 -1
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.js +32 -2
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewState.d.ts +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/acceptChargeCardTermsEpic.js +5 -1
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/enableChargeCardAutoPayEpic.d.ts +11 -0
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/enableChargeCardAutoPayEpic.js +54 -0
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
- package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.d.ts +2 -1
- package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js +21 -11
- package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.js +1 -0
- package/lib/view/spendManagement/plaidAccount/plaidAccountViewState.d.ts +1 -1
- package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailReducer.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initiateChargeCardRepaymentEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const amount_1 = require("../../../../commonStateTypes/amount");
|
|
7
|
+
const chargeCardRepaymentReducer_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentReducer");
|
|
8
|
+
const companyReducer_1 = require("../../../../entity/company/companyReducer");
|
|
9
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
10
|
+
const zeniDayJS_1 = require("../../../../zeniDayJS");
|
|
11
|
+
const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
12
|
+
const helpers_1 = require("../../helpers");
|
|
13
|
+
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
14
|
+
const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
15
|
+
const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
|
|
16
|
+
const chargeCardRepaymentDetailReducer_1 = require("./chargeCardRepaymentDetailReducer");
|
|
17
|
+
const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardRepaymentDetailReducer_1.initiateChargeCardRepayment.match), (0, operators_1.switchMap)((action) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const state = state$.value;
|
|
20
|
+
const { companyId } = action.payload;
|
|
21
|
+
const { depositAccountState, paymentAccountState, paymentAccountListState, depositAccountListState, } = state;
|
|
22
|
+
const localData = state.chargeCardRepaymentDetailState.localData;
|
|
23
|
+
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
24
|
+
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
25
|
+
const allFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
|
|
26
|
+
const transferFromAccountDetail = allFundingAccounts.find((account) => { var _a; return account.id === ((_a = localData.transferFrom) === null || _a === void 0 ? void 0 : _a.id); });
|
|
27
|
+
const payload = {
|
|
28
|
+
funding_account: {
|
|
29
|
+
account_id: (_a = localData.transferFrom) === null || _a === void 0 ? void 0 : _a.id,
|
|
30
|
+
account_type: (_b = (0, helpers_1.accountTypeSubConfigCodeToAccType)(transferFromAccountDetail === null || transferFromAccountDetail === void 0 ? void 0 : transferFromAccountDetail.accType)) !== null && _b !== void 0 ? _b : '',
|
|
31
|
+
},
|
|
32
|
+
idempotency_key: localData.idempotencyKey,
|
|
33
|
+
is_auto_pay_enabled: localData.isAutoRepayment,
|
|
34
|
+
amount: localData.amount.amount,
|
|
35
|
+
};
|
|
36
|
+
if (transferFromAccountDetail != null && localData.transferFrom != null) {
|
|
37
|
+
return zeniAPI
|
|
38
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments`, payload)
|
|
39
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
40
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
41
|
+
const actions = [
|
|
42
|
+
(0, chargeCardRepaymentReducer_1.updateChargeCardRepayment)(response.data.card_repayment),
|
|
43
|
+
(0, chargeCardListReducer_1.updateCreditAccountRepaymentAmountAndDate)({
|
|
44
|
+
amount: (0, amount_1.toAmount)(response.data.card_repayment.amount, response.data.card_repayment.currency_code, response.data.card_repayment.currency_symbol),
|
|
45
|
+
date: (0, zeniDayJS_1.date)(response.data.card_repayment.repayment_date),
|
|
46
|
+
}),
|
|
47
|
+
(0, chargeCardRepaymentDetailReducer_1.updateChargeCardRepaymentStatus)({
|
|
48
|
+
fetchState: 'Completed',
|
|
49
|
+
error: undefined,
|
|
50
|
+
}),
|
|
51
|
+
];
|
|
52
|
+
if (localData.transferFrom != null &&
|
|
53
|
+
(transferFromAccountDetail === null || transferFromAccountDetail === void 0 ? void 0 : transferFromAccountDetail.accType) != null) {
|
|
54
|
+
actions.push((0, companyReducer_1.updateCompanyPrimaryAccount)({
|
|
55
|
+
companyId: companyId,
|
|
56
|
+
primaryFundingAccountId: localData.transferFrom.id,
|
|
57
|
+
accountType: transferFromAccountDetail.accType,
|
|
58
|
+
productType: 'charge_cards',
|
|
59
|
+
}), (0, companyReducer_1.updateEnableAutoPayForChargeCard)({
|
|
60
|
+
companyId: companyId,
|
|
61
|
+
enableAutoPay: localData.isAutoRepayment,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
return (0, rxjs_1.from)(actions);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return (0, rxjs_1.of)((0, chargeCardRepaymentDetailReducer_1.updateChargeCardRepaymentStatus)({
|
|
68
|
+
fetchState: 'Error',
|
|
69
|
+
error: response.status,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
}), (0, operators_1.catchError)((error) => {
|
|
73
|
+
return (0, rxjs_1.of)((0, chargeCardRepaymentDetailReducer_1.updateChargeCardRepaymentStatus)({
|
|
74
|
+
fetchState: 'Error',
|
|
75
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Initiate Charge Card Repayment REST API call errored out' +
|
|
76
|
+
JSON.stringify(error)),
|
|
77
|
+
}));
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return (0, rxjs_1.of)((0, chargeCardRepaymentDetailReducer_1.updateChargeCardRepaymentStatus)({
|
|
82
|
+
fetchState: 'Error',
|
|
83
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Validation Error', 'Funding account not selected.'),
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
exports.initiateChargeCardRepaymentEpic = initiateChargeCardRepaymentEpic;
|
package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.d.ts
CHANGED
|
@@ -5,7 +5,10 @@ export declare const fetchChargeCardSetupView: import("@reduxjs/toolkit").Action
|
|
|
5
5
|
companyId: string;
|
|
6
6
|
cacheOverride: any;
|
|
7
7
|
refreshViewInBackground: any;
|
|
8
|
-
}, "chargeCardSetupView/fetchChargeCardSetupView", never, never>, fetchChargeCardSetupViewSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardSetupView/fetchChargeCardSetupViewSuccess">, fetchChargeCardSetupViewFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[error: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "chargeCardSetupView/fetchChargeCardSetupViewFailure", never, never>,
|
|
8
|
+
}, "chargeCardSetupView/fetchChargeCardSetupView", never, never>, fetchChargeCardSetupViewSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardSetupView/fetchChargeCardSetupViewSuccess">, fetchChargeCardSetupViewFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[error: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "chargeCardSetupView/fetchChargeCardSetupViewFailure", never, never>, enableChargeCardAutoPay: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, isAutoPayEnabled: boolean], {
|
|
9
|
+
companyId: string;
|
|
10
|
+
isAutoPayEnabled: boolean;
|
|
11
|
+
}, "chargeCardSetupView/enableChargeCardAutoPay", never, never>, enableChargeCardAutoPaySuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardSetupView/enableChargeCardAutoPaySuccess">, enableChargeCardAutoPayFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[error: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "chargeCardSetupView/enableChargeCardAutoPayFailure", never, never>, acceptChargeCardTerms: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, enableChargeCard: boolean, chargeCardSetupViewType: "charge_cards" | "debit_cards" | "charge_cards__debit_cards"], {
|
|
9
12
|
companyId: string;
|
|
10
13
|
enableChargeCard: boolean;
|
|
11
14
|
chargeCardSetupViewType: "charge_cards" | "debit_cards" | "charge_cards__debit_cards";
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearChargeCardSetupView = exports.acceptChargeCardTermsFailure = exports.acceptChargeCardTermsSuccess = exports.acceptChargeCardTerms = exports.fetchChargeCardSetupViewFailure = exports.fetchChargeCardSetupViewSuccess = exports.fetchChargeCardSetupView = exports.initialState = void 0;
|
|
4
|
+
exports.clearChargeCardSetupView = exports.acceptChargeCardTermsFailure = exports.acceptChargeCardTermsSuccess = exports.acceptChargeCardTerms = exports.enableChargeCardAutoPayFailure = exports.enableChargeCardAutoPaySuccess = exports.enableChargeCardAutoPay = exports.fetchChargeCardSetupViewFailure = exports.fetchChargeCardSetupViewSuccess = exports.fetchChargeCardSetupView = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
exports.initialState = {
|
|
7
7
|
fetchState: 'Not-Started',
|
|
8
8
|
error: undefined,
|
|
9
9
|
isRefreshingViewInBackground: false,
|
|
10
|
+
earlyPayFetchStatus: {
|
|
11
|
+
fetchState: 'Not-Started',
|
|
12
|
+
error: undefined,
|
|
13
|
+
},
|
|
10
14
|
chargeCardTermsDetails: undefined,
|
|
11
15
|
hasValidState() {
|
|
12
16
|
return this.fetchState === 'Completed';
|
|
@@ -48,6 +52,32 @@ const chargeCardSetupView = (0, toolkit_1.createSlice)({
|
|
|
48
52
|
};
|
|
49
53
|
},
|
|
50
54
|
},
|
|
55
|
+
enableChargeCardAutoPay: {
|
|
56
|
+
reducer(draft) {
|
|
57
|
+
draft.earlyPayFetchStatus.fetchState = 'In-Progress';
|
|
58
|
+
draft.earlyPayFetchStatus.error = undefined;
|
|
59
|
+
},
|
|
60
|
+
prepare(companyId, isAutoPayEnabled) {
|
|
61
|
+
return {
|
|
62
|
+
payload: { companyId, isAutoPayEnabled },
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
enableChargeCardAutoPaySuccess(draft) {
|
|
67
|
+
draft.earlyPayFetchStatus.fetchState = 'Completed';
|
|
68
|
+
draft.earlyPayFetchStatus.error = undefined;
|
|
69
|
+
},
|
|
70
|
+
enableChargeCardAutoPayFailure: {
|
|
71
|
+
reducer(draft, action) {
|
|
72
|
+
draft.earlyPayFetchStatus.fetchState = 'Error';
|
|
73
|
+
draft.earlyPayFetchStatus.error = action.payload;
|
|
74
|
+
},
|
|
75
|
+
prepare(error) {
|
|
76
|
+
return {
|
|
77
|
+
payload: error,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
},
|
|
51
81
|
acceptChargeCardTerms: {
|
|
52
82
|
reducer(draft) {
|
|
53
83
|
draft.chargeCardTermsDetails = Object.assign({}, draft.chargeCardTermsDetails, {
|
|
@@ -87,5 +117,5 @@ const chargeCardSetupView = (0, toolkit_1.createSlice)({
|
|
|
87
117
|
},
|
|
88
118
|
},
|
|
89
119
|
});
|
|
90
|
-
_a = chargeCardSetupView.actions, exports.fetchChargeCardSetupView = _a.fetchChargeCardSetupView, exports.fetchChargeCardSetupViewSuccess = _a.fetchChargeCardSetupViewSuccess, exports.fetchChargeCardSetupViewFailure = _a.fetchChargeCardSetupViewFailure, exports.acceptChargeCardTerms = _a.acceptChargeCardTerms, exports.acceptChargeCardTermsSuccess = _a.acceptChargeCardTermsSuccess, exports.acceptChargeCardTermsFailure = _a.acceptChargeCardTermsFailure, exports.clearChargeCardSetupView = _a.clearChargeCardSetupView;
|
|
120
|
+
_a = chargeCardSetupView.actions, exports.fetchChargeCardSetupView = _a.fetchChargeCardSetupView, exports.fetchChargeCardSetupViewSuccess = _a.fetchChargeCardSetupViewSuccess, exports.fetchChargeCardSetupViewFailure = _a.fetchChargeCardSetupViewFailure, exports.enableChargeCardAutoPay = _a.enableChargeCardAutoPay, exports.enableChargeCardAutoPaySuccess = _a.enableChargeCardAutoPaySuccess, exports.enableChargeCardAutoPayFailure = _a.enableChargeCardAutoPayFailure, exports.acceptChargeCardTerms = _a.acceptChargeCardTerms, exports.acceptChargeCardTermsSuccess = _a.acceptChargeCardTermsSuccess, exports.acceptChargeCardTermsFailure = _a.acceptChargeCardTermsFailure, exports.clearChargeCardSetupView = _a.clearChargeCardSetupView;
|
|
91
121
|
exports.default = chargeCardSetupView.reducer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FetchStateAndError, FetchedState } from '../../../../commonStateTypes/common';
|
|
2
2
|
export interface ChargeCardSetupViewState extends FetchedState {
|
|
3
3
|
isRefreshingViewInBackground: boolean;
|
|
4
|
+
earlyPayFetchStatus: FetchStateAndError;
|
|
4
5
|
chargeCardTermsDetails?: {
|
|
5
6
|
fetchStatus: FetchStateAndError;
|
|
6
7
|
};
|
package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/acceptChargeCardTermsEpic.js
CHANGED
|
@@ -14,12 +14,16 @@ const acceptChargeCardTermsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(
|
|
|
14
14
|
let payload;
|
|
15
15
|
switch (chargeCardSetupViewType) {
|
|
16
16
|
case 'charge_cards':
|
|
17
|
-
payload = Object.assign({ is_charge_cards_tos_accepted: true }, (enableChargeCard && {
|
|
17
|
+
payload = Object.assign({ is_charge_cards_tos_accepted: true }, (enableChargeCard && {
|
|
18
|
+
is_charge_cards_enabled: true,
|
|
19
|
+
is_auto_pay_enabled: true,
|
|
20
|
+
}));
|
|
18
21
|
break;
|
|
19
22
|
case 'charge_cards__debit_cards':
|
|
20
23
|
payload = Object.assign({ is_charge_cards_tos_accepted: true, is_debit_cards_tos_accepted: true }, (enableChargeCard && {
|
|
21
24
|
is_charge_cards_enabled: true,
|
|
22
25
|
is_debit_cards_enabled: true,
|
|
26
|
+
is_auto_pay_enabled: true,
|
|
23
27
|
}));
|
|
24
28
|
break;
|
|
25
29
|
case 'debit_cards':
|
package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/enableChargeCardAutoPayEpic.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { updateCompanies } from '../../../../../entity/company/companyReducer';
|
|
4
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
|
+
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
|
+
import { updateUserRoles } from '../../../../../entity/userRole/userRoleReducer';
|
|
7
|
+
import { RootState } from '../../../../../reducer';
|
|
8
|
+
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
9
|
+
import { enableChargeCardAutoPay, enableChargeCardAutoPayFailure, enableChargeCardAutoPaySuccess } from '../chargeCardSetUpViewReducer';
|
|
10
|
+
export type ActionType = ReturnType<typeof enableChargeCardAutoPay> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateCompanies> | ReturnType<typeof enableChargeCardAutoPaySuccess> | ReturnType<typeof openSnackbar> | ReturnType<typeof enableChargeCardAutoPayFailure>;
|
|
11
|
+
export declare const enableChargeCardAutoPayEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/enableChargeCardAutoPayEpic.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableChargeCardAutoPayEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const companyReducer_1 = require("../../../../../entity/company/companyReducer");
|
|
7
|
+
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
8
|
+
const userReducer_1 = require("../../../../../entity/user/userReducer");
|
|
9
|
+
const userRoleReducer_1 = require("../../../../../entity/userRole/userRoleReducer");
|
|
10
|
+
const responsePayload_1 = require("../../../../../responsePayload");
|
|
11
|
+
const chargeCardSetUpViewReducer_1 = require("../chargeCardSetUpViewReducer");
|
|
12
|
+
const enableChargeCardAutoPayEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardSetUpViewReducer_1.enableChargeCardAutoPay.match), (0, operators_1.mergeMap)((action) => {
|
|
13
|
+
const { isAutoPayEnabled, companyId } = action.payload;
|
|
14
|
+
return zeniAPI
|
|
15
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, { is_auto_pay_enabled: isAutoPayEnabled })
|
|
16
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
17
|
+
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
18
|
+
const actions = [
|
|
19
|
+
(0, userReducer_1.updateAllUsers)({ users: response.data.users }),
|
|
20
|
+
(0, userRoleReducer_1.updateUserRoles)(response.data.user_roles),
|
|
21
|
+
(0, companyReducer_1.updateCompanies)({
|
|
22
|
+
payload: response.data.companies,
|
|
23
|
+
schema: {},
|
|
24
|
+
}),
|
|
25
|
+
(0, chargeCardSetUpViewReducer_1.enableChargeCardAutoPaySuccess)(),
|
|
26
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
27
|
+
messageSection: isAutoPayEnabled
|
|
28
|
+
? 'charge_card_auto_pay_enable'
|
|
29
|
+
: 'charge_card_auto_pay_disable',
|
|
30
|
+
messageText: 'success',
|
|
31
|
+
type: 'success',
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
return (0, rxjs_1.from)(actions);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return (0, rxjs_1.of)((0, chargeCardSetUpViewReducer_1.enableChargeCardAutoPayFailure)(response.status), (0, snackbarReducer_1.openSnackbar)({
|
|
38
|
+
messageSection: isAutoPayEnabled
|
|
39
|
+
? 'charge_card_auto_pay_enable'
|
|
40
|
+
: 'charge_card_auto_pay_disable',
|
|
41
|
+
messageText: 'failed',
|
|
42
|
+
type: 'error',
|
|
43
|
+
variables: [
|
|
44
|
+
{
|
|
45
|
+
variableName: '_api-error_',
|
|
46
|
+
variableValue: response.status.message,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, chargeCardSetUpViewReducer_1.enableChargeCardAutoPayFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Enable Charge Card Auto Pay errored out' +
|
|
52
|
+
JSON.stringify(error))))));
|
|
53
|
+
}));
|
|
54
|
+
exports.enableChargeCardAutoPayEpic = enableChargeCardAutoPayEpic;
|
|
@@ -228,6 +228,7 @@ const mapDepositAccToFundingAccount = (depositAcc) => ({
|
|
|
228
228
|
error: undefined,
|
|
229
229
|
},
|
|
230
230
|
createTime: depositAcc.createTime,
|
|
231
|
+
accountLast4: depositAcc.accountLast4,
|
|
231
232
|
});
|
|
232
233
|
exports.mapDepositAccToFundingAccount = mapDepositAccToFundingAccount;
|
|
233
234
|
const mapPaymentAccToFundingAccount = (paymentAcc, paymentAccountBalanceFetchStatus) => {
|
|
@@ -252,6 +253,7 @@ const mapPaymentAccToFundingAccount = (paymentAcc, paymentAccountBalanceFetchSta
|
|
|
252
253
|
error: undefined,
|
|
253
254
|
},
|
|
254
255
|
createTime: paymentAcc.createTime,
|
|
256
|
+
accountLast4: paymentAcc.accountLast4Digits,
|
|
255
257
|
});
|
|
256
258
|
};
|
|
257
259
|
exports.mapPaymentAccToFundingAccount = mapPaymentAccToFundingAccount;
|
package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { ZeniAPI } from '../../../../../zeniAPI';
|
|
|
10
10
|
import { fetchBillingAccountsView } from '../../../../settingsView/settingsViewReducer';
|
|
11
11
|
import { updateUserBankAccount } from '../../../../userFinancialAccount/userFinancialAccountReducer';
|
|
12
12
|
import { updateNewAddedBillPaymentAccount } from '../../../billPay/editBillView/editBillViewReducer';
|
|
13
|
+
import { updateNewAddedChargeCardPaymentAccount } from '../../../chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer';
|
|
13
14
|
import { updatePaymentAccountList } from '../../../zeniAccounts/paymentAccountList/paymentAccountListReducer';
|
|
14
15
|
import { establishPlaidConnection, establishPlaidConnectionFailure, establishPlaidConnectionSuccess, getPaymentAccounts } from '../../plaidAccountViewReducer';
|
|
15
|
-
export type ActionType = ReturnType<typeof establishPlaidConnection> | ReturnType<typeof updateAccounts> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof updateUserBankAccount> | ReturnType<typeof updatePaymentAccounts> | ReturnType<typeof openSnackbar> | ReturnType<typeof updatePaymentAccountList> | ReturnType<typeof getPaymentAccounts> | ReturnType<typeof establishPlaidConnectionSuccess> | ReturnType<typeof establishPlaidConnectionFailure> | ReturnType<typeof fetchBillingAccountsView> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateNewAddedBillPaymentAccount>;
|
|
16
|
+
export type ActionType = ReturnType<typeof establishPlaidConnection> | ReturnType<typeof updateAccounts> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof updateUserBankAccount> | ReturnType<typeof updatePaymentAccounts> | ReturnType<typeof openSnackbar> | ReturnType<typeof updatePaymentAccountList> | ReturnType<typeof getPaymentAccounts> | ReturnType<typeof establishPlaidConnectionSuccess> | ReturnType<typeof establishPlaidConnectionFailure> | ReturnType<typeof fetchBillingAccountsView> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateNewAddedBillPaymentAccount> | ReturnType<typeof updateNewAddedChargeCardPaymentAccount>;
|
|
16
17
|
export declare const establishPlaidConnectionEpic: (actions$: ActionsObservable<ActionType>, state: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js
CHANGED
|
@@ -6,11 +6,14 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const accountReducer_1 = require("../../../../../entity/account/accountReducer");
|
|
7
7
|
const bankAccountReducer_1 = require("../../../../../entity/bankAccount/bankAccountReducer");
|
|
8
8
|
const companyReducer_1 = require("../../../../../entity/company/companyReducer");
|
|
9
|
+
const paymentAccountPayload_1 = require("../../../../../entity/paymentAccount/paymentAccountPayload");
|
|
9
10
|
const paymentAccountReducer_1 = require("../../../../../entity/paymentAccount/paymentAccountReducer");
|
|
10
11
|
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
11
12
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
12
13
|
const userFinancialAccountReducer_1 = require("../../../../userFinancialAccount/userFinancialAccountReducer");
|
|
13
14
|
const editBillViewReducer_1 = require("../../../billPay/editBillView/editBillViewReducer");
|
|
15
|
+
const chargeCardRepaymentDetailReducer_1 = require("../../../chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer");
|
|
16
|
+
const setupViewSelector_1 = require("../../../commonSetup/setupViewSelector");
|
|
14
17
|
const helpers_1 = require("../../../helpers");
|
|
15
18
|
const paymentAccountListReducer_1 = require("../../../zeniAccounts/paymentAccountList/paymentAccountListReducer");
|
|
16
19
|
const plaidAccountViewReducer_1 = require("../../plaidAccountViewReducer");
|
|
@@ -21,6 +24,7 @@ const establishPlaidConnectionEpic = (actions$, state, zeniAPI) => actions$.pipe
|
|
|
21
24
|
public_token: publicToken,
|
|
22
25
|
};
|
|
23
26
|
const queryPayload = {};
|
|
27
|
+
const paymentAccountListState = state.value.paymentAccountListState;
|
|
24
28
|
const userId = (_b = (_a = state.value.tenantState.loggedInUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : '';
|
|
25
29
|
//setupViewType not passed means this is a user account
|
|
26
30
|
if (linkTokenType !== 'link_external_account') {
|
|
@@ -54,7 +58,7 @@ const establishPlaidConnectionEpic = (actions$, state, zeniAPI) => actions$.pipe
|
|
|
54
58
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/public-token${queryString}`, requestPayload)
|
|
55
59
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
56
60
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
57
|
-
const
|
|
61
|
+
const paymentAccountPayload = response.data.payment_accounts[0];
|
|
58
62
|
const actions = [
|
|
59
63
|
(0, paymentAccountReducer_1.updatePaymentAccounts)(response.data.payment_accounts),
|
|
60
64
|
(0, paymentAccountListReducer_1.updatePaymentAccountList)({
|
|
@@ -64,7 +68,13 @@ const establishPlaidConnectionEpic = (actions$, state, zeniAPI) => actions$.pipe
|
|
|
64
68
|
(0, plaidAccountViewReducer_1.establishPlaidConnectionSuccess)(linkTokenType, plaidAccountKeyType),
|
|
65
69
|
];
|
|
66
70
|
if (plaidAccountKeyType === 'bill_pay_detail') {
|
|
67
|
-
actions.push((0, editBillViewReducer_1.updateNewAddedBillPaymentAccount)(
|
|
71
|
+
actions.push((0, editBillViewReducer_1.updateNewAddedBillPaymentAccount)(paymentAccountPayload.payment_account_id));
|
|
72
|
+
}
|
|
73
|
+
//added through credit card repayment flow
|
|
74
|
+
if (plaidAccountKeyType === 'charge_card_payment') {
|
|
75
|
+
const paymentAccount = (0, paymentAccountPayload_1.toPaymentAccount)(paymentAccountPayload);
|
|
76
|
+
const fundingAccount = (0, setupViewSelector_1.mapPaymentAccToFundingAccount)(paymentAccount, paymentAccountListState.paymentAccountBalanceFetchStatus);
|
|
77
|
+
actions.push((0, chargeCardRepaymentDetailReducer_1.updateNewAddedChargeCardPaymentAccount)(fundingAccount));
|
|
68
78
|
}
|
|
69
79
|
if (setupViewType != null) {
|
|
70
80
|
const primaryAccountForProducts = [];
|
|
@@ -73,37 +83,37 @@ const establishPlaidConnectionEpic = (actions$, state, zeniAPI) => actions$.pipe
|
|
|
73
83
|
if (setupViewType === 'billing') {
|
|
74
84
|
actions.push((0, plaidAccountViewReducer_1.getPaymentAccounts)(setupViewType, plaidAccountKeyType, false));
|
|
75
85
|
}
|
|
76
|
-
if (
|
|
86
|
+
if (paymentAccountPayload.is_primary_for_bill_pay === true) {
|
|
77
87
|
primaryAccountForProducts.push('bill_pay');
|
|
78
88
|
}
|
|
79
|
-
if (
|
|
89
|
+
if (paymentAccountPayload.is_primary_for_bill_pay === true) {
|
|
80
90
|
actions.push((0, companyReducer_1.updateCompanyPrimaryAccount)({
|
|
81
91
|
companyId: companyId,
|
|
82
|
-
primaryFundingAccountId:
|
|
92
|
+
primaryFundingAccountId: paymentAccountPayload.payment_account_id,
|
|
83
93
|
accountType: 'paymentAccount',
|
|
84
94
|
productType: 'bill_pay',
|
|
85
95
|
}));
|
|
86
96
|
}
|
|
87
|
-
if (
|
|
97
|
+
if (paymentAccountPayload.is_primary_for_reimbursements === true) {
|
|
88
98
|
actions.push((0, companyReducer_1.updateCompanyPrimaryAccount)({
|
|
89
99
|
companyId: companyId,
|
|
90
|
-
primaryFundingAccountId:
|
|
100
|
+
primaryFundingAccountId: paymentAccountPayload.payment_account_id,
|
|
91
101
|
accountType: 'paymentAccount',
|
|
92
102
|
productType: 'reimbursement',
|
|
93
103
|
}));
|
|
94
104
|
}
|
|
95
|
-
if (
|
|
105
|
+
if (paymentAccountPayload.is_primary_for_charge_cards === true) {
|
|
96
106
|
actions.push((0, companyReducer_1.updateCompanyPrimaryAccount)({
|
|
97
107
|
companyId: companyId,
|
|
98
|
-
primaryFundingAccountId:
|
|
108
|
+
primaryFundingAccountId: paymentAccountPayload.payment_account_id,
|
|
99
109
|
accountType: 'paymentAccount',
|
|
100
110
|
productType: 'charge_cards',
|
|
101
111
|
}));
|
|
102
112
|
}
|
|
103
|
-
if (
|
|
113
|
+
if (paymentAccountPayload.is_primary_for_deposit_accounts === true) {
|
|
104
114
|
actions.push((0, companyReducer_1.updateCompanyPrimaryAccount)({
|
|
105
115
|
companyId: companyId,
|
|
106
|
-
primaryFundingAccountId:
|
|
116
|
+
primaryFundingAccountId: paymentAccountPayload.payment_account_id,
|
|
107
117
|
accountType: 'paymentAccount',
|
|
108
118
|
productType: 'zeni_accounts',
|
|
109
119
|
}));
|
|
@@ -12,6 +12,7 @@ exports.initialState = {
|
|
|
12
12
|
reimbursement_setup: plaidAccountViewState_1.initialPlaidAccountState,
|
|
13
13
|
account_setup: plaidAccountViewState_1.initialPlaidAccountState,
|
|
14
14
|
charge_card_setup: plaidAccountViewState_1.initialPlaidAccountState,
|
|
15
|
+
charge_card_payment: plaidAccountViewState_1.initialPlaidAccountState,
|
|
15
16
|
user_reimbursement_account: plaidAccountViewState_1.initialPlaidAccountState,
|
|
16
17
|
external_account: plaidAccountViewState_1.initialPlaidAccountState,
|
|
17
18
|
billing_setup: plaidAccountViewState_1.initialPlaidAccountState,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
3
3
|
export type PlaidLinkTokenType = 'link_account' | 'update_account' | 'link_account_no_microdeposit' | 'link_external_account';
|
|
4
|
-
export type PlaidAccountKeyType = 'spend_management_setup' | 'bill_pay_setup' | 'bill_pay_detail' | 'reimbursement_setup' | 'account_setup' | 'charge_card_setup' | 'user_reimbursement_account' | 'external_account' | 'billing_setup' | 'expense_automation_reconcile' | 'treasury_setup';
|
|
4
|
+
export type PlaidAccountKeyType = 'spend_management_setup' | 'bill_pay_setup' | 'bill_pay_detail' | 'reimbursement_setup' | 'account_setup' | 'charge_card_setup' | 'charge_card_payment' | 'user_reimbursement_account' | 'external_account' | 'billing_setup' | 'expense_automation_reconcile' | 'treasury_setup';
|
|
5
5
|
export type PlaidConnectionDetails = Record<PlaidLinkTokenType, {
|
|
6
6
|
linkToken?: string;
|
|
7
7
|
expiration?: ZeniDate;
|
|
@@ -58,6 +58,7 @@ const transferDetail = (0, toolkit_1.createSlice)({
|
|
|
58
58
|
accountBalance: action.payload.accountBalance,
|
|
59
59
|
logo: undefined,
|
|
60
60
|
zeniAccountId: undefined,
|
|
61
|
+
accountLast4: action.payload.accountLast4,
|
|
61
62
|
balanceFetchStatus: {
|
|
62
63
|
fetchState: 'Completed',
|
|
63
64
|
error: undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.17.
|
|
3
|
+
"version": "4.17.49",
|
|
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",
|