@zeniai/client-epic-state 4.19.24-betaRR15 → 4.19.24-betaRR16

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.
@@ -1,8 +1,12 @@
1
+ import { ID } from '../../../../commonStateTypes/common';
1
2
  import { ZeniAPIStatus } from '../../../../responsePayload';
2
3
  import { ChargeCardPaymentHistoryDownloadUIState, ChargeCardPaymentHistoryState, PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
3
4
  import { ChargeCardPaymentHistoryPayload } from './chargeCardPaymentHistoryPayload';
4
5
  export declare const initialState: ChargeCardPaymentHistoryState;
5
- export declare const fetchChargeCardPaymentPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
6
+ export declare const addRepaymentToChargeCardPaymentHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
7
+ cardRepaymentId: ID;
8
+ zeniCreditAccountId: ID;
9
+ }, "chargeCardPaymentHistory/addRepaymentToChargeCardPaymentHistory">, fetchChargeCardPaymentPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
6
10
  cacheOverride: any;
7
11
  }, "chargeCardPaymentHistory/fetchChargeCardPaymentPage", never, never>, fetchChargeCardPaymentHistory: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardPaymentHistory/fetchChargeCardPaymentHistory">, updateChargeCardPaymentHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<ChargeCardPaymentHistoryPayload, "chargeCardPaymentHistory/updateChargeCardPaymentHistory">, updateChargeCardPaymentHistoryFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "chargeCardPaymentHistory/updateChargeCardPaymentHistoryFailure">, clearChargeCardPaymentHistory: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"chargeCardPaymentHistory/clearChargeCardPaymentHistory">, updatePaymentHistoryFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
12
  filters: PaymentHistoryFilters;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updatePaymentHistoryUIState = exports.updatePaymentHistoryDownloadUIState = exports.updatePaymentHistorySearchText = exports.updatePaymentHistoryFilters = exports.clearChargeCardPaymentHistory = exports.updateChargeCardPaymentHistoryFailure = exports.updateChargeCardPaymentHistory = exports.fetchChargeCardPaymentHistory = exports.fetchChargeCardPaymentPage = exports.initialState = void 0;
4
+ exports.updatePaymentHistoryUIState = exports.updatePaymentHistoryDownloadUIState = exports.updatePaymentHistorySearchText = exports.updatePaymentHistoryFilters = exports.clearChargeCardPaymentHistory = exports.updateChargeCardPaymentHistoryFailure = exports.updateChargeCardPaymentHistory = exports.fetchChargeCardPaymentHistory = exports.fetchChargeCardPaymentPage = exports.addRepaymentToChargeCardPaymentHistory = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const chargeCardPaymentHistory_1 = require("./chargeCardPaymentHistory");
7
7
  exports.initialState = chargeCardPaymentHistory_1.initialChargeCardPaymentHistoryState;
@@ -40,6 +40,17 @@ const chargeCardPaymentHistory = (0, toolkit_1.createSlice)({
40
40
  draft.fetchState = 'Error';
41
41
  draft.error = action.payload;
42
42
  },
43
+ addRepaymentToChargeCardPaymentHistory(draft, action) {
44
+ const { cardRepaymentId, zeniCreditAccountId } = action.payload;
45
+ if (draft.creditAccountId !== zeniCreditAccountId) {
46
+ return;
47
+ }
48
+ if (draft.repaymentHistoryIds.includes(cardRepaymentId)) {
49
+ return;
50
+ }
51
+ draft.repaymentHistoryIds.unshift(cardRepaymentId);
52
+ draft.totalRepayments += 1;
53
+ },
43
54
  clearChargeCardPaymentHistory(draft) {
44
55
  Object.assign(draft, exports.initialState);
45
56
  },
@@ -72,5 +83,5 @@ const chargeCardPaymentHistory = (0, toolkit_1.createSlice)({
72
83
  },
73
84
  },
74
85
  });
75
- _a = chargeCardPaymentHistory.actions, exports.fetchChargeCardPaymentPage = _a.fetchChargeCardPaymentPage, exports.fetchChargeCardPaymentHistory = _a.fetchChargeCardPaymentHistory, exports.updateChargeCardPaymentHistory = _a.updateChargeCardPaymentHistory, exports.updateChargeCardPaymentHistoryFailure = _a.updateChargeCardPaymentHistoryFailure, exports.clearChargeCardPaymentHistory = _a.clearChargeCardPaymentHistory, exports.updatePaymentHistoryFilters = _a.updatePaymentHistoryFilters, exports.updatePaymentHistorySearchText = _a.updatePaymentHistorySearchText, exports.updatePaymentHistoryDownloadUIState = _a.updatePaymentHistoryDownloadUIState, exports.updatePaymentHistoryUIState = _a.updatePaymentHistoryUIState;
86
+ _a = chargeCardPaymentHistory.actions, exports.addRepaymentToChargeCardPaymentHistory = _a.addRepaymentToChargeCardPaymentHistory, exports.fetchChargeCardPaymentPage = _a.fetchChargeCardPaymentPage, exports.fetchChargeCardPaymentHistory = _a.fetchChargeCardPaymentHistory, exports.updateChargeCardPaymentHistory = _a.updateChargeCardPaymentHistory, exports.updateChargeCardPaymentHistoryFailure = _a.updateChargeCardPaymentHistoryFailure, exports.clearChargeCardPaymentHistory = _a.clearChargeCardPaymentHistory, exports.updatePaymentHistoryFilters = _a.updatePaymentHistoryFilters, exports.updatePaymentHistorySearchText = _a.updatePaymentHistorySearchText, exports.updatePaymentHistoryDownloadUIState = _a.updatePaymentHistoryDownloadUIState, exports.updatePaymentHistoryUIState = _a.updatePaymentHistoryUIState;
76
87
  exports.default = chargeCardPaymentHistory.reducer;
@@ -6,6 +6,7 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
6
6
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
7
7
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
8
8
  const getChargeCardRepaymentDetail = (state) => {
9
+ var _a;
9
10
  const { chargeCardRepaymentDetailState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
10
11
  const { localData, fetchState, error } = chargeCardRepaymentDetailState;
11
12
  const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
@@ -15,6 +16,9 @@ const getChargeCardRepaymentDetail = (state) => {
15
16
  paymentAccountsView.fetchState === 'Completed') {
16
17
  transferFromAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
17
18
  }
19
+ // #region agent log
20
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'chargeCardRepaymentDetailSelector.ts:selector', message: 'transferFromAccounts data flow', data: { depositFetchState: depositAccountsView.fetchState, paymentFetchState: paymentAccountsView.fetchState, depositAccountsCount: depositAccountsView.depositAccounts.length, paymentAccountsCount: paymentAccountsView.paymentAccounts.length, transferFromAccountsCount: transferFromAccounts.length, enteredIfBlock: depositAccountsView.fetchState === 'Completed' && paymentAccountsView.fetchState === 'Completed', accountIdsLength: (_a = depositAccountListState.accountIds) === null || _a === void 0 ? void 0 : _a.length, depositAccTypes: transferFromAccounts.map(a => a.accType) }, timestamp: Date.now(), hypothesisId: 'H1' }) }).catch(() => { });
21
+ // #endregion
18
22
  const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
19
23
  depositAccountsView,
20
24
  paymentAccountsView,
@@ -7,13 +7,17 @@ const depositAccountListReducer_1 = require("../../zeniAccounts/depositAccountLi
7
7
  const paymentAccountListReducer_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListReducer");
8
8
  const chargeCardRepaymentDetailReducer_1 = require("./chargeCardRepaymentDetailReducer");
9
9
  const fetchChargeCardRepaymentDetailEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(chargeCardRepaymentDetailReducer_1.fetchChargeCardRepaymentDetail.match), (0, operators_1.mergeMap)(() => {
10
+ var _a;
10
11
  const fetchChargeCardRepaymentDetailActions = [];
11
12
  const state = state$.value;
12
13
  const depositAccounts = state.depositAccountListState;
13
- if (depositAccounts.fetchState !== 'In-Progress' &&
14
- depositAccounts.fetchState !== 'Completed') {
14
+ const willFetchDeposit = depositAccounts.fetchState !== 'In-Progress' && depositAccounts.fetchState !== 'Completed';
15
+ if (willFetchDeposit) {
15
16
  fetchChargeCardRepaymentDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
16
17
  }
18
+ // #region agent log
19
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'fetchChargeCardRepaymentDetailEpic.ts:epic', message: 'fetchChargeCardRepaymentDetailEpic dispatch', data: { depositListFetchState: depositAccounts.fetchState, willFetchDeposit, accountIdsLength: (_a = depositAccounts.accountIds) === null || _a === void 0 ? void 0 : _a.length }, timestamp: Date.now(), hypothesisId: 'H3' }) }).catch(() => { });
20
+ // #endregion
17
21
  const paymentAccounts = state.paymentAccountListState;
18
22
  if (paymentAccounts.fetchState !== 'In-Progress' &&
19
23
  paymentAccounts.fetchState !== 'Completed') {
@@ -4,7 +4,8 @@ import { updateChargeCardRepayment } from '../../../../entity/chargeCardRepaymen
4
4
  import { updateCompanyPrimaryAccount, updateEnableAutoPayForChargeCard } from '../../../../entity/company/companyReducer';
5
5
  import { RootState } from '../../../../reducer';
6
6
  import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { addRepaymentToChargeCardPaymentHistory } from '../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer';
7
8
  import { updateCreditAccountRepaymentAmountAndDate } from '../chargeCardList/chargeCardListReducer';
8
9
  import { initiateChargeCardRepayment, updateChargeCardRepaymentStatus } from './chargeCardRepaymentDetailReducer';
9
- export type ActionType = ReturnType<typeof initiateChargeCardRepayment> | ReturnType<typeof updateChargeCardRepayment> | ReturnType<typeof updateCreditAccountRepaymentAmountAndDate> | ReturnType<typeof updateChargeCardRepaymentStatus> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateEnableAutoPayForChargeCard>;
10
+ export type ActionType = ReturnType<typeof addRepaymentToChargeCardPaymentHistory> | ReturnType<typeof initiateChargeCardRepayment> | ReturnType<typeof updateChargeCardRepayment> | ReturnType<typeof updateCreditAccountRepaymentAmountAndDate> | ReturnType<typeof updateChargeCardRepaymentStatus> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateEnableAutoPayForChargeCard>;
10
11
  export declare const initiateChargeCardRepaymentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -12,6 +12,7 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
12
12
  const helpers_1 = require("../../helpers");
13
13
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
14
14
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
15
+ const chargeCardPaymentHistoryReducer_1 = require("../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer");
15
16
  const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
16
17
  const chargeCardRepaymentDetailReducer_1 = require("./chargeCardRepaymentDetailReducer");
17
18
  const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardRepaymentDetailReducer_1.initiateChargeCardRepayment.match), (0, operators_1.switchMap)((action) => {
@@ -40,6 +41,10 @@ const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.
40
41
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
41
42
  const actions = [
42
43
  (0, chargeCardRepaymentReducer_1.updateChargeCardRepayment)(response.data.card_repayment),
44
+ (0, chargeCardPaymentHistoryReducer_1.addRepaymentToChargeCardPaymentHistory)({
45
+ cardRepaymentId: response.data.card_repayment.card_repayment_id,
46
+ zeniCreditAccountId: response.data.card_repayment.zeni_credit_account_id,
47
+ }),
43
48
  (0, chargeCardListReducer_1.updateCreditAccountRepaymentAmountAndDate)({
44
49
  amount: (0, amount_1.toAmount)(response.data.card_repayment.amount, response.data.card_repayment.currency_code, response.data.card_repayment.currency_symbol),
45
50
  date: (0, zeniDayJS_1.date)(response.data.card_repayment.repayment_date),
@@ -11,12 +11,16 @@ const fetchDepositAccountListEpic = (actions$, _state$, zeniAPI) => actions$.pip
11
11
  return zeniAPI
12
12
  .getJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent(`{"is_include_deposit_accounts_summary":true}`)}`)
13
13
  .pipe((0, operators_1.mergeMap)((response) => {
14
- var _a, _b, _c, _d, _e;
14
+ var _a, _b, _c, _d, _e, _f, _g;
15
15
  if ((0, responsePayload_1.isSuccessResponse)(response)) {
16
- return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.deposit_accounts) !== null && _b !== void 0 ? _b : []), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
17
- summaryPayload: (_c = response.data) === null || _c === void 0 ? void 0 : _c.all_deposit_accounts_summary,
16
+ // #region agent log
17
+ const depositAccounts = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.deposit_accounts) !== null && _b !== void 0 ? _b : [];
18
+ fetch('http://127.0.0.1:7242/ingest/3d86d94d-63fc-405c-92bd-d68a0fc3a8c8', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '88d521' }, body: JSON.stringify({ sessionId: '88d521', location: 'fetchDepositAccountListEpic.ts:epic', message: 'deposit-accounts API response', data: { depositAccountsCount: depositAccounts.length, accountIds: depositAccounts.map((a) => a === null || a === void 0 ? void 0 : a.deposit_account_id) }, timestamp: Date.now(), hypothesisId: 'H5' }) }).catch(() => { });
19
+ // #endregion
20
+ return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.deposit_accounts) !== null && _d !== void 0 ? _d : []), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
21
+ summaryPayload: (_e = response.data) === null || _e === void 0 ? void 0 : _e.all_deposit_accounts_summary,
18
22
  }), (0, depositAccountListReducer_1.updateDepositAccountList)({
19
- data: (_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.deposit_accounts) !== null && _e !== void 0 ? _e : [],
23
+ data: (_g = (_f = response.data) === null || _f === void 0 ? void 0 : _f.deposit_accounts) !== null && _g !== void 0 ? _g : [],
20
24
  updateType: 'replace',
21
25
  }));
22
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.24-betaRR15",
3
+ "version": "4.19.24-betaRR16",
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",