@zeniai/client-epic-state 4.19.8-betaRR3 → 4.19.8-betaRR4
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.
|
@@ -4,13 +4,16 @@ import { ChargeCardRepayment } from '../../../../entity/chargeCardRepayment/char
|
|
|
4
4
|
import { User } from '../../../../entity/user/userState';
|
|
5
5
|
import { RootState } from '../../../../reducer';
|
|
6
6
|
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
7
|
+
export interface ChargeCardRepaymentWithUser extends ChargeCardRepayment {
|
|
8
|
+
paidByUser?: User;
|
|
9
|
+
}
|
|
7
10
|
export interface ChargeCardPaymentHistorySelectorView extends SelectorView {
|
|
8
11
|
creditAccountId: ID;
|
|
9
12
|
currencyCode: string;
|
|
10
13
|
currencySymbol: string;
|
|
11
14
|
filters: PaymentHistoryFilters;
|
|
12
15
|
isAutoPayEnabled: boolean;
|
|
13
|
-
repaymentHistory:
|
|
16
|
+
repaymentHistory: ChargeCardRepaymentWithUser[];
|
|
14
17
|
repaymentHistoryIds: ID[];
|
|
15
18
|
repaymentHistoryUsers: User[];
|
|
16
19
|
searchText: string;
|
|
@@ -35,35 +35,45 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
35
35
|
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState } = state;
|
|
36
36
|
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, repaymentHistoryUserIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
37
37
|
// Get the full repayment details from the entity state
|
|
38
|
-
|
|
38
|
+
const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
|
|
39
|
+
// Get users first to enrich repayments
|
|
40
|
+
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
41
|
+
// Create a map of userId -> User for quick lookup
|
|
42
|
+
const userMap = new Map();
|
|
43
|
+
repaymentHistoryUsers.forEach((user) => {
|
|
44
|
+
userMap.set(user.userId, user);
|
|
45
|
+
});
|
|
46
|
+
// Enrich repayments with paidByUser details
|
|
47
|
+
let repaymentHistoryWithUsers = repaymentHistory.map((repayment) => (Object.assign(Object.assign({}, repayment), { paidByUser: userMap.get(repayment.paidById) })));
|
|
39
48
|
// Apply filters
|
|
40
|
-
|
|
49
|
+
repaymentHistoryWithUsers = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('charge_card_payment_history', repaymentHistoryWithUsers, filters);
|
|
41
50
|
// Apply search text filtering
|
|
42
51
|
const loweredSearchText = searchText.trim().toLowerCase();
|
|
43
52
|
if (loweredSearchText.length > 0) {
|
|
44
|
-
|
|
53
|
+
repaymentHistoryWithUsers = repaymentHistoryWithUsers.filter((repayment) => {
|
|
45
54
|
var _a, _b;
|
|
46
55
|
const amountString = repayment.amount.amount.toString();
|
|
47
56
|
const statusString = repayment.status.toLowerCase();
|
|
48
|
-
const initiatedByString = repayment.
|
|
57
|
+
const initiatedByString = repayment.repaymentType === 'scheduled'
|
|
58
|
+
? 'autopay'
|
|
59
|
+
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
49
60
|
const accountInfo = accountInfoMap === null || accountInfoMap === void 0 ? void 0 : accountInfoMap.get(repayment.providerDepositAccountId);
|
|
50
61
|
const accountNameString = (_b = (_a = accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.depositAccountName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
51
62
|
return (amountString.includes(loweredSearchText) ||
|
|
52
63
|
statusString.includes(loweredSearchText) ||
|
|
53
|
-
initiatedByString.includes(loweredSearchText) ||
|
|
64
|
+
initiatedByString.toLowerCase().includes(loweredSearchText) ||
|
|
54
65
|
accountNameString.includes(loweredSearchText));
|
|
55
66
|
});
|
|
56
67
|
}
|
|
57
68
|
// Apply sorting
|
|
58
|
-
|
|
59
|
-
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
69
|
+
repaymentHistoryWithUsers = sortPaymentHistory(repaymentHistoryWithUsers, uiState.sortKey, uiState.sortOrder, accountInfoMap);
|
|
60
70
|
return {
|
|
61
71
|
creditAccountId,
|
|
62
72
|
currencyCode,
|
|
63
73
|
currencySymbol,
|
|
64
74
|
filters,
|
|
65
75
|
isAutoPayEnabled,
|
|
66
|
-
repaymentHistory,
|
|
76
|
+
repaymentHistory: repaymentHistoryWithUsers,
|
|
67
77
|
repaymentHistoryIds,
|
|
68
78
|
repaymentHistoryUsers,
|
|
69
79
|
searchText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.8-
|
|
3
|
+
"version": "4.19.8-betaRR4",
|
|
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",
|