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

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.
@@ -5,6 +5,8 @@ const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchStat
5
5
  const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector");
6
6
  const userSelector_1 = require("../../../../entity/user/userSelector");
7
7
  const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
8
+ const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
9
+ const paymentAccountSelector_1 = require("../../../../entity/paymentAccount/paymentAccountSelector");
8
10
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
9
11
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
10
12
  const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
@@ -31,12 +33,37 @@ const getChargeCardPaymentHistoryView = (state) => {
31
33
  .map((repayment) => repayment.paymentAccountId)
32
34
  .filter((id) => id !== undefined && id !== null)));
33
35
  let fundingAccountsForMap = [];
34
- if (repaymentHistoryFundingAccountIdsForMap.length > 0 &&
35
- depositAccountsView.fetchState === 'Completed' &&
36
- paymentAccountsView.fetchState === 'Completed') {
37
- const matchingDepositAccountsForMap = depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIdsForMap.includes(depositAccount.id));
38
- const matchingPaymentAccountsForMap = paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIdsForMap.includes(paymentAccount.paymentAccountId));
39
- fundingAccountsForMap = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccountsForMap, matchingPaymentAccountsForMap, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
36
+ if (repaymentHistoryFundingAccountIdsForMap.length > 0) {
37
+ const hasDepositData = depositAccountsView.fetchState === 'Completed';
38
+ const hasPaymentData = paymentAccountsView.fetchState === 'Completed';
39
+ if (hasDepositData || hasPaymentData) {
40
+ const matchingDepositAccountsForMap = hasDepositData
41
+ ? depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIdsForMap.includes(depositAccount.id))
42
+ : [];
43
+ const matchingPaymentAccountsForMap = hasPaymentData
44
+ ? paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIdsForMap.includes(paymentAccount.paymentAccountId))
45
+ : [];
46
+ fundingAccountsForMap = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccountsForMap, matchingPaymentAccountsForMap, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
47
+ // Fallback: look up repayment-referenced accounts directly from entity stores
48
+ // in case they're not in the list state (e.g. race condition, stale list)
49
+ const existingIds = new Set(fundingAccountsForMap.map((fa) => fa.id).filter(Boolean));
50
+ for (const accountId of repaymentHistoryFundingAccountIdsForMap) {
51
+ if (existingIds.has(accountId)) {
52
+ continue;
53
+ }
54
+ const depositAccount = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, accountId);
55
+ if (depositAccount != null) {
56
+ fundingAccountsForMap.push((0, setupViewSelector_1.mapDepositAccToFundingAccount)(depositAccount));
57
+ existingIds.add(accountId);
58
+ continue;
59
+ }
60
+ const paymentAccount = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, accountId);
61
+ if (paymentAccount != null) {
62
+ fundingAccountsForMap.push((0, setupViewSelector_1.mapPaymentAccToFundingAccount)(paymentAccount, paymentAccountListState.paymentAccountBalanceFetchStatus));
63
+ existingIds.add(accountId);
64
+ }
65
+ }
66
+ }
40
67
  }
41
68
  const accountInfoByAccountId = {};
42
69
  fundingAccountsForMap.forEach((fa) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.24-betaRR14",
3
+ "version": "4.19.24-betaRR15",
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",