@zeniai/client-epic-state 4.14.78 → 4.14.79

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.
Files changed (38) hide show
  1. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -0
  2. package/lib/entity/depositAccountTransaction/depositAccountTransactionPayload.d.ts +1 -0
  3. package/lib/entity/depositAccountTransaction/depositAccountTransactionPayload.js +1 -0
  4. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  5. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  6. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  7. package/lib/entity/tenant/clearAllEpic.js +2 -0
  8. package/lib/epic.d.ts +3 -1
  9. package/lib/epic.js +3 -1
  10. package/lib/index.d.ts +5 -2
  11. package/lib/index.js +20 -12
  12. package/lib/init.js +1 -1
  13. package/lib/reducer.d.ts +3 -0
  14. package/lib/reducer.js +3 -0
  15. package/lib/view/bankAccountView/bankAccountViewState.d.ts +1 -1
  16. package/lib/view/bankAccountView/epic/createBankAccountEpic.d.ts +2 -1
  17. package/lib/view/bankAccountView/epic/createBankAccountEpic.js +18 -4
  18. package/lib/view/bankAccountView/epic/createInternationalBankAccountEpic.js +4 -2
  19. package/lib/view/commonVendorView/vendorView/epics/saveVendorEpic.d.ts +2 -1
  20. package/lib/view/commonVendorView/vendorView/epics/saveVendorEpic.js +49 -24
  21. package/lib/view/commonVendorView/vendorView/vendorViewPayload.js +2 -2
  22. package/lib/view/commonVendorView/vendorView/vendorViewReducer.d.ts +5 -2
  23. package/lib/view/commonVendorView/vendorView/vendorViewReducer.js +30 -3
  24. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.d.ts +7 -1
  25. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.js +3 -2
  26. package/lib/view/spendManagement/billPay/internationalWire/epics/createInternationalPaymentInstrumentEpic.js +4 -2
  27. package/lib/view/spendManagement/zeniAccounts/depositAccountTransactionList/depositAccountTransactionListSelector.js +1 -1
  28. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/fetchExpressPayInitialDetailsEpic.d.ts +10 -0
  29. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/fetchExpressPayInitialDetailsEpic.js +46 -0
  30. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/submitExpressPayEpic.d.ts +8 -0
  31. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/submitExpressPayEpic.js +67 -0
  32. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPayReducer.d.ts +15 -0
  33. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPayReducer.js +61 -0
  34. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.d.ts +27 -0
  35. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.js +85 -0
  36. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPayState.d.ts +19 -0
  37. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPayState.js +2 -0
  38. package/package.json +1 -1
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.submitExpressPayEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
7
+ const responsePayload_1 = require("../../../../../responsePayload");
8
+ const saveBillDetailEpic_1 = require("../../../billPay/editBillView/epics/saveBillDetailEpic");
9
+ const expressPayReducer_1 = require("../expressPayReducer");
10
+ const submitExpressPayEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(expressPayReducer_1.submitExpressPay.match), (0, operators_1.switchMap)(() => {
11
+ const { expressPayState } = state$.value;
12
+ const localData = expressPayState.formLocalData;
13
+ if (localData != null) {
14
+ return zeniAPI
15
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/transactions/express-pay`, toExpressPayPayload(localData))
16
+ .pipe((0, operators_1.mergeMap)((response) => {
17
+ const actions = [];
18
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
+ actions.push((0, expressPayReducer_1.updateExpressPaySubmissionStatus)({
20
+ fetchState: 'Completed',
21
+ error: undefined,
22
+ }));
23
+ actions.push((0, snackbarReducer_1.openSnackbar)({
24
+ messageSection: 'express_pay_submit',
25
+ messageText: 'success',
26
+ type: 'success',
27
+ }));
28
+ }
29
+ else {
30
+ actions.push((0, expressPayReducer_1.updateExpressPaySubmissionStatus)({
31
+ fetchState: 'Error',
32
+ error: response.status,
33
+ }));
34
+ actions.push((0, snackbarReducer_1.openSnackbar)({
35
+ messageSection: 'express_pay_submit',
36
+ messageText: 'failed',
37
+ type: 'error',
38
+ }));
39
+ }
40
+ return (0, rxjs_1.from)(actions);
41
+ }), (0, operators_1.catchError)((error) => {
42
+ return (0, rxjs_1.of)((0, expressPayReducer_1.updateExpressPaySubmissionStatus)({
43
+ fetchState: 'Error',
44
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Submit express pay REST API call errored out' +
45
+ JSON.stringify(error)),
46
+ }));
47
+ }));
48
+ }
49
+ else {
50
+ return (0, rxjs_1.from)([]);
51
+ }
52
+ }));
53
+ exports.submitExpressPayEpic = submitExpressPayEpic;
54
+ const toExpressPayPayload = (localData) => {
55
+ var _a;
56
+ const paymentMethodType = (0, saveBillDetailEpic_1.getBillPaymentMethodTypePayload)(localData.paymentType);
57
+ return {
58
+ to_bank_account_id: localData.paymentToAccountId,
59
+ vendor_id: localData.vendorId,
60
+ amount: localData.amount.amount,
61
+ payment_method_type: paymentMethodType.code,
62
+ payment_method_sub_type: paymentMethodType.sub_code,
63
+ source_deposit_account_id: (_a = localData.withdrawFrom) === null || _a === void 0 ? void 0 : _a.id,
64
+ payment_date: localData.paymentDate.format('YYYY-MM-DD'),
65
+ file_id: localData.receiptFileId,
66
+ };
67
+ };
@@ -0,0 +1,15 @@
1
+ import { FetchState } from '../../../../commonStateTypes/common';
2
+ import { ZeniAPIStatus } from '../../../../responsePayload';
3
+ import { ExpressPayFormLocalData, ExpressPayState } from './expressPayState';
4
+ export declare const initialState: ExpressPayState;
5
+ export declare const fetchExpressPayInitialDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride: boolean, isInternationalWireEnabled: boolean], {
6
+ cacheOverride: boolean;
7
+ isInternationalWireEnabled: boolean;
8
+ }, "expressPay/fetchExpressPayInitialDetails", never, never>, updateExpressPayFetchState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expressPay/updateExpressPayFetchState">, updateExpressPayFormLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
9
+ localData: ExpressPayFormLocalData;
10
+ }, "expressPay/updateExpressPayFormLocalData">, submitExpressPay: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expressPay/submitExpressPay">, updateExpressPaySubmissionStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
11
+ fetchState: FetchState;
12
+ error?: ZeniAPIStatus;
13
+ }, "expressPay/updateExpressPaySubmissionStatus">, resetExpressPayLocalData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expressPay/resetExpressPayLocalData">, clearExpressPayView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expressPay/clearExpressPayView">;
14
+ declare const _default: import("redux").Reducer<ExpressPayState>;
15
+ export default _default;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearExpressPayView = exports.resetExpressPayLocalData = exports.updateExpressPaySubmissionStatus = exports.submitExpressPay = exports.updateExpressPayFormLocalData = exports.updateExpressPayFetchState = exports.fetchExpressPayInitialDetails = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ const zeniDayJS_1 = require("../../../../zeniDayJS");
7
+ exports.initialState = {
8
+ formLocalData: {
9
+ amount: {
10
+ amount: 0,
11
+ currencyCode: 'USD',
12
+ currencySymbol: '$',
13
+ },
14
+ paymentDate: (0, zeniDayJS_1.dateNow)(),
15
+ },
16
+ fetchState: 'Not-Started',
17
+ expressPaySubmitStatus: { fetchState: 'Not-Started' },
18
+ };
19
+ const expressPay = (0, toolkit_1.createSlice)({
20
+ name: 'expressPay',
21
+ initialState: exports.initialState,
22
+ reducers: {
23
+ fetchExpressPayInitialDetails: {
24
+ reducer(draft) {
25
+ draft.fetchState = 'In-Progress';
26
+ },
27
+ prepare(cacheOverride, isInternationalWireEnabled) {
28
+ return {
29
+ payload: {
30
+ cacheOverride,
31
+ isInternationalWireEnabled,
32
+ },
33
+ };
34
+ },
35
+ },
36
+ updateExpressPayFetchState(draft) {
37
+ draft.fetchState = 'Completed';
38
+ draft.error = undefined;
39
+ },
40
+ updateExpressPayFormLocalData(draft, action) {
41
+ draft.formLocalData = action.payload.localData;
42
+ },
43
+ submitExpressPay(draft) {
44
+ draft.expressPaySubmitStatus.fetchState = 'In-Progress';
45
+ draft.expressPaySubmitStatus.error = undefined;
46
+ },
47
+ updateExpressPaySubmissionStatus(draft, action) {
48
+ const { fetchState, error } = action.payload;
49
+ draft.expressPaySubmitStatus.fetchState = fetchState;
50
+ draft.expressPaySubmitStatus.error = error;
51
+ },
52
+ resetExpressPayLocalData(draft) {
53
+ draft.formLocalData = exports.initialState.formLocalData;
54
+ },
55
+ clearExpressPayView(draft) {
56
+ Object.assign(draft, exports.initialState);
57
+ },
58
+ },
59
+ });
60
+ _a = expressPay.actions, exports.fetchExpressPayInitialDetails = _a.fetchExpressPayInitialDetails, exports.updateExpressPayFetchState = _a.updateExpressPayFetchState, exports.updateExpressPayFormLocalData = _a.updateExpressPayFormLocalData, exports.submitExpressPay = _a.submitExpressPay, exports.updateExpressPaySubmissionStatus = _a.updateExpressPaySubmissionStatus, exports.resetExpressPayLocalData = _a.resetExpressPayLocalData, exports.clearExpressPayView = _a.clearExpressPayView;
61
+ exports.default = expressPay.reducer;
@@ -0,0 +1,27 @@
1
+ import { AllowedValueWithCode } from '../../../../commonStateTypes/allowedValue';
2
+ import { FetchState, FetchStateAndError, ID } from '../../../../commonStateTypes/common';
3
+ import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
4
+ import { File } from '../../../../entity/file/fileState';
5
+ import { RootState } from '../../../../reducer';
6
+ import { VendorViewSelectorView } from '../../../commonVendorView/vendorView/vendorViewSelector';
7
+ import { VendorType } from '../../../vendorTypeList/vendorTypeListPayload';
8
+ import { BillPayConfig } from '../../billPay/billPayConfig/billPayConfigState';
9
+ import { PaymentDetailsSectionView, PaymentToOption } from '../../billPay/editBillView/editBillViewSelector';
10
+ import { FundingAccount } from '../../commonSetup/setupViewSelector';
11
+ import { ExpressPayFormLocalData } from './expressPayState';
12
+ export interface ExpressPayView extends SelectorView {
13
+ vendorViewDetails: VendorViewSelectorView;
14
+ vendorTypeList: VendorType[];
15
+ expressPayLocalData?: ExpressPayFormLocalData;
16
+ paymentDetails?: PaymentDetailsSectionView;
17
+ paymentToOptions: PaymentToOption[];
18
+ allPaymentMethods: BillPayConfig[];
19
+ withdrawFromList: FundingAccount[];
20
+ receiptFile?: File;
21
+ internationalWireOnboardingStatus?: AllowedValueWithCode;
22
+ deleteFileStatusById: Record<ID, FetchStateAndError | undefined>;
23
+ updateFileStatusById: Record<ID, FetchStateAndError | undefined>;
24
+ vendorSaveStatus: FetchState;
25
+ submitStatus: FetchState;
26
+ }
27
+ export declare const getExpressPayView: (state: RootState) => ExpressPayView;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getExpressPayView = void 0;
4
+ const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
5
+ const bankAccountSelector_1 = require("../../../../entity/bankAccount/bankAccountSelector");
6
+ const fileSelector_1 = require("../../../../entity/file/fileSelector");
7
+ const paymentInstrumentSelector_1 = require("../../../../entity/paymentInstrument/paymentInstrumentSelector");
8
+ const vendorViewSelector_1 = require("../../../commonVendorView/vendorView/vendorViewSelector");
9
+ const getCompanyView_1 = require("../../../companyView/selectorHelpers/getCompanyView");
10
+ const fileViewSelector_1 = require("../../../fileView/fileViewSelector");
11
+ const editBillViewSelector_1 = require("../../billPay/editBillView/editBillViewSelector");
12
+ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
13
+ const depositAccountListSelector_1 = require("../depositAccountList/depositAccountListSelector");
14
+ const getExpressPayView = (state) => {
15
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
16
+ const deleteFileStatusById = {};
17
+ const updateFileStatusById = {};
18
+ const { tenantState, expressPayState, vendorTypeListState, bankAccountState, paymentInstrumentState, billPayConfigState, vendorViewState, depositAccountState, depositAccountListState, paymentAccountListState, } = state;
19
+ const { currentTenantId } = tenantState;
20
+ const companyId = currentTenantId != null
21
+ ? (_b = (_a = tenantState.tenantsById) === null || _a === void 0 ? void 0 : _a[currentTenantId]) === null || _b === void 0 ? void 0 : _b.companyId
22
+ : undefined;
23
+ const companyView = (0, getCompanyView_1.getCompanyView)(state, companyId !== null && companyId !== void 0 ? companyId : '', []);
24
+ const vendorTypeList = vendorTypeListState.vendorTypes;
25
+ const allPaymentMethods = (0, editBillViewSelector_1.getBillPayConfigList)(billPayConfigState);
26
+ const vendorId = (_c = expressPayState.formLocalData) === null || _c === void 0 ? void 0 : _c.vendorId;
27
+ const vendorViewDetails = (0, vendorViewSelector_1.getVendorView)(state, vendorId);
28
+ const vendorLocalData = vendorId != null
29
+ ? (_d = vendorViewDetails.editVendorState) === null || _d === void 0 ? void 0 : _d.vendorDetailLocalData
30
+ : (_e = vendorViewDetails.newVendorState) === null || _e === void 0 ? void 0 : _e.vendorDetailLocalData;
31
+ const vendorSaveStatus = vendorId != null && ((_f = vendorViewState.editVendorStateById) === null || _f === void 0 ? void 0 : _f[vendorId]) != null
32
+ ? vendorViewState.editVendorStateById[vendorId].saveStatus.fetchState
33
+ : (_g = vendorViewState.newVendorState) === null || _g === void 0 ? void 0 : _g.saveStatus.fetchState;
34
+ const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_h = vendorLocalData === null || vendorLocalData === void 0 ? void 0 : vendorLocalData.bankAccountIds) !== null && _h !== void 0 ? _h : []);
35
+ const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_j = vendorLocalData === null || vendorLocalData === void 0 ? void 0 : vendorLocalData.paymentInstrumentIds) !== null && _j !== void 0 ? _j : []);
36
+ const paymentToOptions = [
37
+ ...vendorBankAccounts.map((acc) => (0, editBillViewSelector_1.toPaymentToOption)(acc)),
38
+ ...vendorPaymentInstruments.map((pi) => (0, editBillViewSelector_1.toPaymentToOption)(pi)),
39
+ ];
40
+ const allDepositAccounts = (0, depositAccountListSelector_1.getAllDepostAccounts)(depositAccountState, depositAccountListState).depositAccounts;
41
+ const withdrawFromList = (0, setupViewSelector_1.getAllFundingAccounts)(allDepositAccounts, [], paymentAccountListState.paymentAccountBalanceFetchStatus);
42
+ const internationalWireOnboardingStatus = companyView === null || companyView === void 0 ? void 0 : companyView.company.company.companyBillPayInfo.internationalWireOnboardingStatus;
43
+ const fileId = (_k = expressPayState.formLocalData) === null || _k === void 0 ? void 0 : _k.receiptFileId;
44
+ let receiptFile;
45
+ if (fileId != null) {
46
+ deleteFileStatusById[fileId] = (0, fileViewSelector_1.getFileDeleteStatusById)(state, fileId);
47
+ updateFileStatusById[fileId] = (0, fileViewSelector_1.getFileUpdateNameStatusById)(state, fileId);
48
+ receiptFile = (0, fileSelector_1.getFileByFileId)(state.fileState, fileId);
49
+ }
50
+ const fetchState = (0, reduceFetchState_1.reduceFetchState)([
51
+ {
52
+ fetchState: vendorTypeListState.fetchState,
53
+ error: vendorTypeListState.error,
54
+ },
55
+ {
56
+ fetchState: billPayConfigState.fetchState,
57
+ error: billPayConfigState.error,
58
+ },
59
+ {
60
+ fetchState: depositAccountListState.fetchState,
61
+ error: depositAccountListState.error,
62
+ },
63
+ {
64
+ fetchState: paymentAccountListState.fetchState,
65
+ error: paymentAccountListState.error,
66
+ },
67
+ ]);
68
+ return {
69
+ vendorViewDetails,
70
+ vendorTypeList,
71
+ paymentToOptions,
72
+ allPaymentMethods,
73
+ withdrawFromList,
74
+ internationalWireOnboardingStatus,
75
+ expressPayLocalData: expressPayState.formLocalData,
76
+ receiptFile,
77
+ deleteFileStatusById,
78
+ updateFileStatusById,
79
+ vendorSaveStatus,
80
+ submitStatus: expressPayState.expressPaySubmitStatus.fetchState,
81
+ fetchState: fetchState.fetchState,
82
+ error: fetchState.error,
83
+ };
84
+ };
85
+ exports.getExpressPayView = getExpressPayView;
@@ -0,0 +1,19 @@
1
+ import { Amount } from '../../../../commonStateTypes/amount';
2
+ import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
3
+ import { ZeniDate } from '../../../../zeniDayJS';
4
+ import { BillPayConfig } from '../../billPay/billPayConfig/billPayConfigState';
5
+ import { FundingAccount } from '../../commonSetup/setupViewSelector';
6
+ export interface ExpressPayState extends FetchStateAndError {
7
+ expressPayId?: ID;
8
+ formLocalData?: ExpressPayFormLocalData;
9
+ expressPaySubmitStatus: FetchStateAndError;
10
+ }
11
+ export interface ExpressPayFormLocalData {
12
+ vendorId?: ID;
13
+ withdrawFrom?: FundingAccount;
14
+ paymentToAccountId?: ID;
15
+ paymentType?: BillPayConfig;
16
+ amount: Amount;
17
+ paymentDate: ZeniDate;
18
+ receiptFileId?: ID;
19
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.14.78",
3
+ "version": "4.14.79",
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",