@zeniai/client-epic-state 4.19.24-betaRR9 → 4.19.24
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/chargeCardRepayment/chargeCardRepayment.d.ts +1 -5
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.js +1 -4
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.d.ts +3 -7
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +5 -7
- package/lib/epic.d.ts +1 -3
- package/lib/epic.js +1 -3
- package/lib/index.d.ts +1 -6
- package/lib/index.js +8 -21
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +4 -6
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +2 -31
- package/package.json +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +0 -43
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js +0 -36
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.d.ts +0 -8
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +0 -22
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.d.ts +0 -9
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +0 -70
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.d.ts +0 -13
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.js +0 -2
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +0 -79
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.d.ts +0 -27
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +0 -69
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.d.ts +0 -9
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.js +0 -35
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.d.ts +0 -7
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +0 -35
|
@@ -6,12 +6,10 @@ import { TaskListFilterCategoryField, TaskListFilters } from '../taskManager/tas
|
|
|
6
6
|
import { TaskWithUserDetails } from '../taskManager/taskListView/taskListSelector';
|
|
7
7
|
import { BillTransactionView } from './billPay/billList/billListSelector';
|
|
8
8
|
import { BillListViewFilterCategoryField, BillPayFilters } from './billPay/billList/billListState';
|
|
9
|
-
import { PaymentHistoryFilterCategoryDropdownOption, PaymentHistoryFilters } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory';
|
|
10
|
-
import { ChargeCardRepaymentWithUser } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector';
|
|
11
9
|
import { ReimbursementView } from './reimbursement/remiListView/remiListSelector';
|
|
12
10
|
import { ReimbursementFilters, RemiListViewFilterCategoryField } from './reimbursement/remiListView/remiListState';
|
|
13
|
-
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters
|
|
14
|
-
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management'
|
|
11
|
+
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters;
|
|
12
|
+
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management';
|
|
15
13
|
export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
|
|
16
14
|
export interface MatchingOperatorDropdownOption {
|
|
17
15
|
label: 'is' | 'is not';
|
|
@@ -33,9 +31,9 @@ export interface TaskFilterCategoryDropdownOption {
|
|
|
33
31
|
multiple?: boolean;
|
|
34
32
|
type?: FilterCategoryType;
|
|
35
33
|
}
|
|
36
|
-
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption
|
|
34
|
+
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption;
|
|
37
35
|
export type FilterCategoryValueType = string | number | ZeniDate;
|
|
38
|
-
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[]
|
|
36
|
+
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails)[];
|
|
39
37
|
export declare const isBillListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
40
38
|
export declare const isRemiListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
41
39
|
export declare const hideCreatedByFilter: (userRole: UserRoleType[]) => boolean;
|
|
@@ -73,17 +73,10 @@ const filterItemOnCategoriesWithMultipleValues = (categoryValue, currentFilter)
|
|
|
73
73
|
return true;
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
const getItemId = (item) => {
|
|
77
|
-
if ('cardRepaymentId' in item) {
|
|
78
|
-
return item.cardRepaymentId;
|
|
79
|
-
}
|
|
80
|
-
return item
|
|
81
|
-
.id;
|
|
82
|
-
};
|
|
83
76
|
const removeDuplicatesFromList = (list) => {
|
|
84
77
|
const foundIds = [];
|
|
85
78
|
return list.filter((item) => {
|
|
86
|
-
const itemId =
|
|
79
|
+
const itemId = item.id;
|
|
87
80
|
if (foundIds.indexOf(itemId) === -1) {
|
|
88
81
|
foundIds.push(itemId);
|
|
89
82
|
return true;
|
|
@@ -118,9 +111,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
118
111
|
? getCategoryValueForBill(key, item)
|
|
119
112
|
: entity === 'reimbursement'
|
|
120
113
|
? getCategoryValueForReimbursement(key, item)
|
|
121
|
-
:
|
|
122
|
-
? getCategoryValueForTaskList(key, item)
|
|
123
|
-
: getCategoryValueForPaymentHistory(key, item);
|
|
114
|
+
: getCategoryValueForTaskList(key, item);
|
|
124
115
|
if (categoryValue == null) {
|
|
125
116
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
126
117
|
return true;
|
|
@@ -140,7 +131,6 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
140
131
|
'dueDate',
|
|
141
132
|
'creationDate',
|
|
142
133
|
'receiptDate',
|
|
143
|
-
'repaymentDate',
|
|
144
134
|
]);
|
|
145
135
|
}
|
|
146
136
|
});
|
|
@@ -244,25 +234,6 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
244
234
|
return undefined;
|
|
245
235
|
}
|
|
246
236
|
};
|
|
247
|
-
const getCategoryValueForPaymentHistory = (key, repayment) => {
|
|
248
|
-
switch (key) {
|
|
249
|
-
case 'repaymentDate':
|
|
250
|
-
return repayment.repaymentDate;
|
|
251
|
-
case 'sourceAccount': {
|
|
252
|
-
// Return account identifier - could be deposit account name or ID
|
|
253
|
-
// This will need to be enhanced based on how source accounts are identified
|
|
254
|
-
return repayment.providerDepositAccountId;
|
|
255
|
-
}
|
|
256
|
-
case 'status':
|
|
257
|
-
return repayment.status;
|
|
258
|
-
case 'initiatedBy':
|
|
259
|
-
return repayment.repaymentType === 'scheduled'
|
|
260
|
-
? 'autopay'
|
|
261
|
-
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
262
|
-
default:
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
237
|
const isBillListDownloadable = (state, currentTimePeriod) => {
|
|
267
238
|
const { billListState, billTransactionState, entityApprovalStatusState, userState, } = state;
|
|
268
239
|
const keys = billListState_1.ALL_BILL_TABS.filter((tab) => tab !== 'draft').map((tab) => (0, billListState_1.getBillListKey)(currentTimePeriod, tab));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.24
|
|
3
|
+
"version": "4.19.24",
|
|
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",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"scripts": {
|
|
78
78
|
"clean": "rimraf lib",
|
|
79
79
|
"test:typecheck": "echo 'Typechecking test files...' && time tsc -p tsconfig.typecheck.json",
|
|
80
|
-
"test": "vitest run --typecheck",
|
|
80
|
+
"test": "pnpm test:typecheck && vitest run --typecheck",
|
|
81
81
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
|
82
82
|
"find-dead-code": "ts-prune | grep -v '(used in module)'",
|
|
83
83
|
"find-unused-exports": "ts-unused-exports ./tsconfig.json",
|
package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FetchState, FetchedState, ID } from '../../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniDate } from '../../../../zeniDayJS';
|
|
3
|
-
import { SpendManagementUIState } from '../../billPay/billList/billListState';
|
|
4
|
-
import { CategoryCombinationOperator, FilterCategoryType } from '../../spendManagementFilterHelpers';
|
|
5
|
-
export type PaymentHistorySortKey = 'paymentDate' | 'sourceAccount' | 'paymentStatus' | 'initiatedBy' | 'amount';
|
|
6
|
-
export interface PaymentHistoryUIState extends SpendManagementUIState {
|
|
7
|
-
sortKey: PaymentHistorySortKey;
|
|
8
|
-
}
|
|
9
|
-
export interface ChargeCardPaymentHistoryDownloadUIState {
|
|
10
|
-
downloadState: FetchState;
|
|
11
|
-
}
|
|
12
|
-
export interface ChargeCardPaymentHistoryState extends FetchedState {
|
|
13
|
-
creditAccountId: ID;
|
|
14
|
-
currencyCode: string;
|
|
15
|
-
currencySymbol: string;
|
|
16
|
-
downloadUIState: ChargeCardPaymentHistoryDownloadUIState;
|
|
17
|
-
filters: PaymentHistoryFilters;
|
|
18
|
-
isAutoPayEnabled: boolean;
|
|
19
|
-
repaymentHistoryIds: ID[];
|
|
20
|
-
repaymentHistoryUserIds: ID[];
|
|
21
|
-
repaymentHistoryXlsDownloadUrl: string;
|
|
22
|
-
searchText: string;
|
|
23
|
-
totalRepayments: number;
|
|
24
|
-
uiState: PaymentHistoryUIState;
|
|
25
|
-
}
|
|
26
|
-
export interface PaymentHistoryFilters {
|
|
27
|
-
categories: PaymentHistoryFilterCategory[];
|
|
28
|
-
categoryCombinationOperator: CategoryCombinationOperator;
|
|
29
|
-
}
|
|
30
|
-
export interface PaymentHistoryFilterCategory {
|
|
31
|
-
field: PaymentHistoryFilterCategoryField;
|
|
32
|
-
matchingOperator: 'equal' | 'not-equal';
|
|
33
|
-
values: (string | ZeniDate)[];
|
|
34
|
-
valuesCombinationOperator: 'ANY';
|
|
35
|
-
}
|
|
36
|
-
export type PaymentHistoryFilterCategoryField = 'repaymentDate' | 'sourceAccount' | 'status' | 'initiatedBy';
|
|
37
|
-
export interface PaymentHistoryFilterCategoryDropdownOption {
|
|
38
|
-
value: PaymentHistoryFilterCategoryField;
|
|
39
|
-
multiple?: boolean;
|
|
40
|
-
type?: FilterCategoryType;
|
|
41
|
-
}
|
|
42
|
-
export declare const PAYMENT_HISTORY_FILTER_CATEGORIES: PaymentHistoryFilterCategoryDropdownOption[];
|
|
43
|
-
export declare const initialChargeCardPaymentHistoryState: ChargeCardPaymentHistoryState;
|
package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialChargeCardPaymentHistoryState = exports.PAYMENT_HISTORY_FILTER_CATEGORIES = void 0;
|
|
4
|
-
exports.PAYMENT_HISTORY_FILTER_CATEGORIES = [
|
|
5
|
-
{ value: 'repaymentDate', type: 'dateRange', multiple: true },
|
|
6
|
-
{ value: 'sourceAccount', multiple: true, type: 'dropdown' },
|
|
7
|
-
{ value: 'status', multiple: true, type: 'dropdown' },
|
|
8
|
-
{ value: 'initiatedBy', multiple: true, type: 'dropdown' },
|
|
9
|
-
];
|
|
10
|
-
exports.initialChargeCardPaymentHistoryState = {
|
|
11
|
-
fetchState: 'Not-Started',
|
|
12
|
-
error: undefined,
|
|
13
|
-
creditAccountId: '',
|
|
14
|
-
currencyCode: 'USD',
|
|
15
|
-
currencySymbol: '$',
|
|
16
|
-
downloadUIState: {
|
|
17
|
-
downloadState: 'Not-Started',
|
|
18
|
-
},
|
|
19
|
-
filters: {
|
|
20
|
-
categories: [],
|
|
21
|
-
categoryCombinationOperator: 'AND',
|
|
22
|
-
},
|
|
23
|
-
isAutoPayEnabled: false,
|
|
24
|
-
repaymentHistoryIds: [],
|
|
25
|
-
repaymentHistoryUserIds: [],
|
|
26
|
-
searchText: '',
|
|
27
|
-
totalRepayments: 0,
|
|
28
|
-
repaymentHistoryXlsDownloadUrl: '',
|
|
29
|
-
uiState: {
|
|
30
|
-
sortKey: 'paymentDate',
|
|
31
|
-
sortOrder: 'ascending',
|
|
32
|
-
},
|
|
33
|
-
hasValidState() {
|
|
34
|
-
return this.fetchState === 'Completed';
|
|
35
|
-
},
|
|
36
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
2
|
-
import { RootState } from '../../../../reducer';
|
|
3
|
-
import { ChargeCardRepaymentWithUser } from './chargeCardPaymentHistorySelector';
|
|
4
|
-
export interface ChargeCardPaymentHistoryDownloadReport extends SelectorView {
|
|
5
|
-
reportTitle: string;
|
|
6
|
-
transactions: ChargeCardRepaymentWithUser[];
|
|
7
|
-
}
|
|
8
|
-
export declare const getChargeCardPaymentHistoryDownloadReport: (state: RootState) => ChargeCardPaymentHistoryDownloadReport;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChargeCardPaymentHistoryDownloadReport = void 0;
|
|
4
|
-
const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector");
|
|
5
|
-
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
6
|
-
const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
|
|
7
|
-
const getChargeCardPaymentHistoryDownloadReport = (state) => {
|
|
8
|
-
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, } = state;
|
|
9
|
-
const { filters, repaymentHistoryIds, repaymentHistoryUserIds, searchText, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
10
|
-
const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
|
|
11
|
-
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
12
|
-
const userMap = new Map(repaymentHistoryUsers.map((user) => [user.userId, user]));
|
|
13
|
-
const repaymentHistoryWithUsers = repaymentHistory.map((repayment) => (Object.assign(Object.assign({}, repayment), { paidByUser: userMap.get(repayment.paidById) })));
|
|
14
|
-
const transactions = (0, chargeCardPaymentHistoryHelpers_1.applyPaymentHistoryFiltersSearchAndSort)(repaymentHistoryWithUsers, filters, searchText, uiState);
|
|
15
|
-
return {
|
|
16
|
-
reportTitle: 'Card Payment History',
|
|
17
|
-
fetchState,
|
|
18
|
-
error,
|
|
19
|
-
transactions,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.getChargeCardPaymentHistoryDownloadReport = getChargeCardPaymentHistoryDownloadReport;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ID } from '../../../../commonStateTypes/common';
|
|
2
|
-
import type { ChargeCardRepaymentWithUser } from './chargeCardPaymentHistorySelector';
|
|
3
|
-
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
4
|
-
export declare function getPaymentHistorySourceAccountName(repayment: ChargeCardRepaymentWithUser, accountInfoMap?: Map<ID, {
|
|
5
|
-
depositAccountName?: string;
|
|
6
|
-
}>): string;
|
|
7
|
-
export declare function applyPaymentHistoryFiltersSearchAndSort(repayments: ChargeCardRepaymentWithUser[], filters: PaymentHistoryFilters, searchText: string, uiState: PaymentHistoryUIState, accountInfoMap?: Map<ID, {
|
|
8
|
-
depositAccountName?: string;
|
|
9
|
-
}>): ChargeCardRepaymentWithUser[];
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPaymentHistorySourceAccountName = getPaymentHistorySourceAccountName;
|
|
7
|
-
exports.applyPaymentHistoryFiltersSearchAndSort = applyPaymentHistoryFiltersSearchAndSort;
|
|
8
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
|
-
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
10
|
-
const spendManagementFilterHelpers_1 = require("../../spendManagementFilterHelpers");
|
|
11
|
-
function getPaymentHistorySourceAccountName(repayment, accountInfoMap) {
|
|
12
|
-
var _a, _b, _c;
|
|
13
|
-
return ((_c = (_b = (_a = accountInfoMap === null || accountInfoMap === void 0 ? void 0 : accountInfoMap.get(repayment.providerDepositAccountId)) === null || _a === void 0 ? void 0 : _a.depositAccountName) !== null && _b !== void 0 ? _b : repayment.paymentAccountName) !== null && _c !== void 0 ? _c : '');
|
|
14
|
-
}
|
|
15
|
-
function getPaymentHistorySortValue(repayment, sortKey, accountInfoMap) {
|
|
16
|
-
switch (sortKey) {
|
|
17
|
-
case 'paymentDate':
|
|
18
|
-
return repayment.repaymentDate.valueOf();
|
|
19
|
-
case 'amount':
|
|
20
|
-
return repayment.amount.amount;
|
|
21
|
-
case 'paymentStatus':
|
|
22
|
-
return repayment.status;
|
|
23
|
-
case 'initiatedBy':
|
|
24
|
-
return repayment.repaymentType === 'scheduled'
|
|
25
|
-
? 'autopay'
|
|
26
|
-
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
27
|
-
case 'sourceAccount':
|
|
28
|
-
return getPaymentHistorySourceAccountName(repayment, accountInfoMap);
|
|
29
|
-
default:
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function sortPaymentHistory(repayments, sortKey, sortOrder, accountInfoMap) {
|
|
34
|
-
const getColumnWiseSortOrder = (sortOrder) => {
|
|
35
|
-
switch (sortKey) {
|
|
36
|
-
case 'sourceAccount':
|
|
37
|
-
case 'paymentStatus':
|
|
38
|
-
case 'initiatedBy':
|
|
39
|
-
return sortOrder === 'ascending' ? 'asc' : 'desc';
|
|
40
|
-
default:
|
|
41
|
-
return sortOrder === 'ascending' ? 'desc' : 'asc';
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const order = getColumnWiseSortOrder(sortOrder);
|
|
45
|
-
return (0, orderBy_1.default)(repayments, (repayment) => getPaymentHistorySortValue(repayment, sortKey, accountInfoMap), [order]);
|
|
46
|
-
}
|
|
47
|
-
function filterPaymentHistoryBySearchText(repayments, searchText, accountInfoMap) {
|
|
48
|
-
const loweredSearchText = searchText.trim().toLowerCase();
|
|
49
|
-
if (loweredSearchText.length === 0) {
|
|
50
|
-
return repayments;
|
|
51
|
-
}
|
|
52
|
-
return repayments.filter((repayment) => {
|
|
53
|
-
const amountString = repayment.amount.amount.toString();
|
|
54
|
-
const statusString = repayment.status.toLowerCase();
|
|
55
|
-
const initiatedByString = repayment.repaymentType === 'scheduled'
|
|
56
|
-
? 'autopay'
|
|
57
|
-
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
58
|
-
const accountNameString = getPaymentHistorySourceAccountName(repayment, accountInfoMap).toLowerCase();
|
|
59
|
-
return (amountString.includes(loweredSearchText) ||
|
|
60
|
-
statusString.includes(loweredSearchText) ||
|
|
61
|
-
initiatedByString.toLowerCase().includes(loweredSearchText) ||
|
|
62
|
-
accountNameString.includes(loweredSearchText));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function applyPaymentHistoryFiltersSearchAndSort(repayments, filters, searchText, uiState, accountInfoMap) {
|
|
66
|
-
let result = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('charge_card_payment_history', repayments, filters);
|
|
67
|
-
result = filterPaymentHistoryBySearchText(result, searchText, accountInfoMap);
|
|
68
|
-
result = sortPaymentHistory(result, uiState.sortKey, uiState.sortOrder, accountInfoMap);
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ChargeCardRepaymentPayload } from '../../../../entity/chargeCardRepayment/chargeCardRepaymentPayload';
|
|
2
|
-
import { ZeniAPIResponse } from '../../../../responsePayload';
|
|
3
|
-
export interface ChargeCardPaymentHistoryPayload {
|
|
4
|
-
credit_account_id: string;
|
|
5
|
-
currency_code: string;
|
|
6
|
-
currency_symbol: string;
|
|
7
|
-
is_auto_pay_enabled: boolean;
|
|
8
|
-
repayment_history: RepaymentHistoryPayload[];
|
|
9
|
-
total_repayments: number;
|
|
10
|
-
}
|
|
11
|
-
type RepaymentHistoryPayload = Omit<ChargeCardRepaymentPayload, 'is_deleted' | 'provider_counterparty_account_id'>;
|
|
12
|
-
export type FetchChargeCardPaymentHistoryResponse = ZeniAPIResponse<ChargeCardPaymentHistoryPayload>;
|
|
13
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ZeniAPIStatus } from '../../../../responsePayload';
|
|
2
|
-
import { ChargeCardPaymentHistoryDownloadUIState, ChargeCardPaymentHistoryState, PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
3
|
-
import { ChargeCardPaymentHistoryPayload } from './chargeCardPaymentHistoryPayload';
|
|
4
|
-
export declare const initialState: ChargeCardPaymentHistoryState;
|
|
5
|
-
export declare const fetchChargeCardPaymentPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
|
|
6
|
-
cacheOverride: any;
|
|
7
|
-
}, "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
|
-
filters: PaymentHistoryFilters;
|
|
9
|
-
}, "chargeCardPaymentHistory/updatePaymentHistoryFilters">, updatePaymentHistorySearchText: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "chargeCardPaymentHistory/updatePaymentHistorySearchText">, updatePaymentHistoryDownloadUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
10
|
-
uiState: Partial<ChargeCardPaymentHistoryDownloadUIState>;
|
|
11
|
-
}, "chargeCardPaymentHistory/updatePaymentHistoryDownloadUIState">, updatePaymentHistoryUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
12
|
-
uiState: Partial<PaymentHistoryUIState>;
|
|
13
|
-
}, "chargeCardPaymentHistory/updatePaymentHistoryUIState">;
|
|
14
|
-
declare const _default: import("redux").Reducer<ChargeCardPaymentHistoryState>;
|
|
15
|
-
export default _default;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
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;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const chargeCardPaymentHistory_1 = require("./chargeCardPaymentHistory");
|
|
7
|
-
exports.initialState = chargeCardPaymentHistory_1.initialChargeCardPaymentHistoryState;
|
|
8
|
-
const chargeCardPaymentHistory = (0, toolkit_1.createSlice)({
|
|
9
|
-
name: 'chargeCardPaymentHistory',
|
|
10
|
-
initialState: exports.initialState,
|
|
11
|
-
reducers: {
|
|
12
|
-
fetchChargeCardPaymentPage: {
|
|
13
|
-
reducer() {
|
|
14
|
-
// do nothing
|
|
15
|
-
},
|
|
16
|
-
prepare(cacheOverride = false) {
|
|
17
|
-
return {
|
|
18
|
-
payload: {
|
|
19
|
-
cacheOverride,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
fetchChargeCardPaymentHistory(draft) {
|
|
25
|
-
draft.fetchState = 'In-Progress';
|
|
26
|
-
draft.error = undefined;
|
|
27
|
-
},
|
|
28
|
-
updateChargeCardPaymentHistory(draft, action) {
|
|
29
|
-
const payload = action.payload;
|
|
30
|
-
draft.creditAccountId = payload.credit_account_id;
|
|
31
|
-
draft.currencyCode = payload.currency_code;
|
|
32
|
-
draft.currencySymbol = payload.currency_symbol;
|
|
33
|
-
draft.isAutoPayEnabled = payload.is_auto_pay_enabled;
|
|
34
|
-
draft.repaymentHistoryIds = payload.repayment_history.map((repayment) => repayment.card_repayment_id);
|
|
35
|
-
draft.repaymentHistoryUserIds = payload.repayment_history
|
|
36
|
-
.map((repayment) => { var _a; return (_a = repayment.paid_by_user) === null || _a === void 0 ? void 0 : _a.user_id; })
|
|
37
|
-
.filter((userId) => userId != null);
|
|
38
|
-
draft.totalRepayments = payload.total_repayments;
|
|
39
|
-
draft.fetchState = 'Completed';
|
|
40
|
-
draft.error = undefined;
|
|
41
|
-
},
|
|
42
|
-
updateChargeCardPaymentHistoryFailure(draft, action) {
|
|
43
|
-
draft.fetchState = 'Error';
|
|
44
|
-
draft.error = action.payload;
|
|
45
|
-
},
|
|
46
|
-
clearChargeCardPaymentHistory(draft) {
|
|
47
|
-
Object.assign(draft, exports.initialState);
|
|
48
|
-
},
|
|
49
|
-
updatePaymentHistoryFilters(draft, action) {
|
|
50
|
-
if (action.payload.filters != null) {
|
|
51
|
-
draft.filters = action.payload.filters;
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
updatePaymentHistorySearchText(draft, action) {
|
|
55
|
-
if (action.payload != null) {
|
|
56
|
-
draft.searchText = action.payload;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
updatePaymentHistoryUIState(draft, action) {
|
|
60
|
-
if (action.payload.uiState.sortKey != null) {
|
|
61
|
-
draft.uiState.sortKey = action.payload.uiState.sortKey;
|
|
62
|
-
}
|
|
63
|
-
if (action.payload.uiState.sortOrder != null) {
|
|
64
|
-
draft.uiState.sortOrder = action.payload.uiState.sortOrder;
|
|
65
|
-
}
|
|
66
|
-
if (action.payload.uiState.scrollYOffset != null) {
|
|
67
|
-
draft.uiState.scrollYOffset = action.payload.uiState.scrollYOffset;
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
updatePaymentHistoryDownloadUIState(draft, action) {
|
|
71
|
-
if (action.payload.uiState.downloadState != null) {
|
|
72
|
-
draft.downloadUIState.downloadState =
|
|
73
|
-
action.payload.uiState.downloadState;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
_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;
|
|
79
|
-
exports.default = chargeCardPaymentHistory.reducer;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ID } from '../../../../commonStateTypes/common';
|
|
2
|
-
import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
|
-
import { ChargeCardRepayment } from '../../../../entity/chargeCardRepayment/chargeCardRepayment';
|
|
4
|
-
import { User } from '../../../../entity/user/userState';
|
|
5
|
-
import { RootState } from '../../../../reducer';
|
|
6
|
-
import { FundingAccount } from '../../commonSetup/setupViewSelector';
|
|
7
|
-
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
8
|
-
export interface ChargeCardRepaymentWithUser extends ChargeCardRepayment {
|
|
9
|
-
paidByUser?: User;
|
|
10
|
-
}
|
|
11
|
-
export interface ChargeCardPaymentHistorySelectorView extends SelectorView {
|
|
12
|
-
creditAccountId: ID;
|
|
13
|
-
currencyCode: string;
|
|
14
|
-
currencySymbol: string;
|
|
15
|
-
filters: PaymentHistoryFilters;
|
|
16
|
-
isAutoPayEnabled: boolean;
|
|
17
|
-
repaymentHistory: ChargeCardRepaymentWithUser[];
|
|
18
|
-
repaymentHistoryFundingAccounts: FundingAccount[];
|
|
19
|
-
repaymentHistoryIds: ID[];
|
|
20
|
-
repaymentHistoryUsers: User[];
|
|
21
|
-
searchText: string;
|
|
22
|
-
totalRepayments: number;
|
|
23
|
-
uiState: PaymentHistoryUIState;
|
|
24
|
-
}
|
|
25
|
-
export declare const getChargeCardPaymentHistoryView: (state: RootState, accountInfoMap?: Map<ID, {
|
|
26
|
-
depositAccountName?: string;
|
|
27
|
-
}>) => ChargeCardPaymentHistorySelectorView;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChargeCardPaymentHistoryView = void 0;
|
|
4
|
-
const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
|
|
5
|
-
const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector");
|
|
6
|
-
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
7
|
-
const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
8
|
-
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
9
|
-
const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
10
|
-
const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
|
|
11
|
-
const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
12
|
-
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
|
|
13
|
-
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, repaymentHistoryUserIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
14
|
-
// Get the full repayment details from the entity state
|
|
15
|
-
const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
|
|
16
|
-
// Get users first to enrich repayments
|
|
17
|
-
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
18
|
-
// Create a map of userId -> User for quick lookup
|
|
19
|
-
const userMap = new Map();
|
|
20
|
-
repaymentHistoryUsers.forEach((user) => {
|
|
21
|
-
userMap.set(user.userId, user);
|
|
22
|
-
});
|
|
23
|
-
// Enrich repayments with paidByUser details
|
|
24
|
-
let repaymentHistoryWithUsers = repaymentHistory.map((repayment) => (Object.assign(Object.assign({}, repayment), { paidByUser: userMap.get(repayment.paidById) })));
|
|
25
|
-
repaymentHistoryWithUsers = (0, chargeCardPaymentHistoryHelpers_1.applyPaymentHistoryFiltersSearchAndSort)(repaymentHistoryWithUsers, filters, searchText, uiState, accountInfoMap);
|
|
26
|
-
// Extract unique funding account IDs from repayment history
|
|
27
|
-
const repaymentHistoryFundingAccountIds = Array.from(new Set(repaymentHistoryWithUsers
|
|
28
|
-
.map((repayment) => repayment.providerDepositAccountId)
|
|
29
|
-
.filter((id) => id !== undefined && id !== null)));
|
|
30
|
-
// Get deposit and payment accounts views for fetch state reduction
|
|
31
|
-
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
32
|
-
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
33
|
-
// Get funding accounts linked to payments
|
|
34
|
-
let repaymentHistoryFundingAccounts = [];
|
|
35
|
-
if (repaymentHistoryFundingAccountIds.length > 0 &&
|
|
36
|
-
depositAccountsView.fetchState === 'Completed' &&
|
|
37
|
-
paymentAccountsView.fetchState === 'Completed') {
|
|
38
|
-
// Filter deposit accounts that match providerDepositAccountIds (by id)
|
|
39
|
-
const matchingDepositAccounts = depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIds.includes(depositAccount.id));
|
|
40
|
-
// Filter payment accounts that match providerDepositAccountIds (by providerAccountId)
|
|
41
|
-
const matchingPaymentAccounts = paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIds.includes(paymentAccount.providerAccountId));
|
|
42
|
-
// Convert to FundingAccount[] format
|
|
43
|
-
repaymentHistoryFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccounts, matchingPaymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
|
|
44
|
-
}
|
|
45
|
-
const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
46
|
-
{ fetchState, error },
|
|
47
|
-
depositAccountsView,
|
|
48
|
-
paymentAccountsView,
|
|
49
|
-
...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
|
|
50
|
-
]);
|
|
51
|
-
return {
|
|
52
|
-
creditAccountId,
|
|
53
|
-
currencyCode,
|
|
54
|
-
currencySymbol,
|
|
55
|
-
filters,
|
|
56
|
-
isAutoPayEnabled,
|
|
57
|
-
repaymentHistory: repaymentHistoryWithUsers,
|
|
58
|
-
repaymentHistoryFundingAccounts,
|
|
59
|
-
repaymentHistoryIds,
|
|
60
|
-
repaymentHistoryUsers,
|
|
61
|
-
searchText,
|
|
62
|
-
totalRepayments,
|
|
63
|
-
uiState,
|
|
64
|
-
fetchState: reducedFetchState.fetchState,
|
|
65
|
-
error: reducedFetchState.error,
|
|
66
|
-
version: 0,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.getChargeCardPaymentHistoryView = getChargeCardPaymentHistoryView;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateChargeCardRepayments } from '../../../../entity/chargeCardRepayment/chargeCardRepaymentReducer';
|
|
4
|
-
import { updateAllUsers } from '../../../../entity/user/userReducer';
|
|
5
|
-
import { RootState } from '../../../../reducer';
|
|
6
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
7
|
-
import { fetchChargeCardPaymentHistory, updateChargeCardPaymentHistory, updateChargeCardPaymentHistoryFailure } from './chargeCardPaymentHistoryReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof fetchChargeCardPaymentHistory> | ReturnType<typeof updateChargeCardPaymentHistory> | ReturnType<typeof updateChargeCardPaymentHistoryFailure> | ReturnType<typeof updateChargeCardRepayments> | ReturnType<typeof updateAllUsers>;
|
|
9
|
-
export declare const fetchChargeCardPaymentHistoryEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchChargeCardPaymentHistoryEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const chargeCardRepaymentReducer_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentReducer");
|
|
7
|
-
const userReducer_1 = require("../../../../entity/user/userReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
-
const chargeCardPaymentHistoryReducer_1 = require("./chargeCardPaymentHistoryReducer");
|
|
10
|
-
const fetchChargeCardPaymentHistoryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardPaymentHistoryReducer_1.fetchChargeCardPaymentHistory.match), (0, operators_1.switchMap)(() => {
|
|
11
|
-
const queryParams = { include_history: true };
|
|
12
|
-
const queryString = encodeURIComponent(JSON.stringify(queryParams));
|
|
13
|
-
return zeniAPI
|
|
14
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments?query=${queryString}`)
|
|
15
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
16
|
-
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
17
|
-
return (0, rxjs_1.of)(
|
|
18
|
-
// Store repayments FIRST before marking as completed
|
|
19
|
-
(0, chargeCardRepaymentReducer_1.updateChargeCardRepayments)(response.data.repayment_history), (0, userReducer_1.updateAllUsers)({
|
|
20
|
-
users: response.data.repayment_history
|
|
21
|
-
.map((repayment) => repayment.paid_by_user)
|
|
22
|
-
.filter((user) => user != null),
|
|
23
|
-
}),
|
|
24
|
-
// Mark as completed LAST, after all data is stored
|
|
25
|
-
(0, chargeCardPaymentHistoryReducer_1.updateChargeCardPaymentHistory)(response.data));
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return (0, rxjs_1.of)((0, chargeCardPaymentHistoryReducer_1.updateChargeCardPaymentHistoryFailure)(response.status));
|
|
29
|
-
}
|
|
30
|
-
}), (0, operators_1.catchError)((error) => {
|
|
31
|
-
return (0, rxjs_1.of)((0, chargeCardPaymentHistoryReducer_1.updateChargeCardPaymentHistoryFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch charge card payment history REST API call errored out' +
|
|
32
|
-
JSON.stringify(error))));
|
|
33
|
-
}));
|
|
34
|
-
}));
|
|
35
|
-
exports.fetchChargeCardPaymentHistoryEpic = fetchChargeCardPaymentHistoryEpic;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../../../reducer';
|
|
4
|
-
import { fetchChargeCardRepaymentDetail } from '../chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer';
|
|
5
|
-
import { fetchChargeCardPaymentHistory, fetchChargeCardPaymentPage } from './chargeCardPaymentHistoryReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchChargeCardPaymentPage> | ReturnType<typeof fetchChargeCardPaymentHistory> | ReturnType<typeof fetchChargeCardRepaymentDetail>;
|
|
7
|
-
export declare const fetchChargeCardPaymentPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchChargeCardPaymentPageEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const chargeCardRepaymentDetailReducer_1 = require("../chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer");
|
|
7
|
-
const chargeCardPaymentHistoryReducer_1 = require("./chargeCardPaymentHistoryReducer");
|
|
8
|
-
const fetchChargeCardPaymentPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(chargeCardPaymentHistoryReducer_1.fetchChargeCardPaymentPage.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { cacheOverride } = action.payload;
|
|
10
|
-
const chargeCardPaymentPageActions = [];
|
|
11
|
-
const state = state$.value;
|
|
12
|
-
const chargeCardPaymentHistoryState = state.chargeCardPaymentHistoryState;
|
|
13
|
-
if (cacheOverride === true) {
|
|
14
|
-
chargeCardPaymentPageActions.push((0, chargeCardPaymentHistoryReducer_1.fetchChargeCardPaymentHistory)());
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
if (chargeCardPaymentHistoryState.fetchState !== 'Completed' &&
|
|
18
|
-
chargeCardPaymentHistoryState.fetchState !== 'In-Progress') {
|
|
19
|
-
chargeCardPaymentPageActions.push((0, chargeCardPaymentHistoryReducer_1.fetchChargeCardPaymentHistory)());
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// Fetch repayment detail if deposit or payment accounts are not fetched
|
|
23
|
-
//These are needed to get the transfer from accounts for the repayment history
|
|
24
|
-
const depositAccountListState = state.depositAccountListState;
|
|
25
|
-
const paymentAccountListState = state.paymentAccountListState;
|
|
26
|
-
const needsRepaymentDetailFetch = (depositAccountListState.fetchState !== 'Completed' &&
|
|
27
|
-
depositAccountListState.fetchState !== 'In-Progress') ||
|
|
28
|
-
(paymentAccountListState.fetchState !== 'Completed' &&
|
|
29
|
-
paymentAccountListState.fetchState !== 'In-Progress');
|
|
30
|
-
if (needsRepaymentDetailFetch) {
|
|
31
|
-
chargeCardPaymentPageActions.push((0, chargeCardRepaymentDetailReducer_1.fetchChargeCardRepaymentDetail)());
|
|
32
|
-
}
|
|
33
|
-
return (0, rxjs_1.concat)((0, rxjs_1.from)(chargeCardPaymentPageActions));
|
|
34
|
-
}));
|
|
35
|
-
exports.fetchChargeCardPaymentPageEpic = fetchChargeCardPaymentPageEpic;
|