@zeniai/client-epic-state 4.15.84 → 4.15.85

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 (129) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +1 -1
  3. package/lib/entity/chargeCard/chargeCard.d.ts +26 -8
  4. package/lib/entity/chargeCard/chargeCard.js +25 -6
  5. package/lib/entity/chargeCard/chargeCardPayload.d.ts +41 -5
  6. package/lib/entity/chargeCard/chargeCardPayload.js +20 -8
  7. package/lib/entity/company/companyPayload.d.ts +12 -1
  8. package/lib/entity/company/companyPayload.js +14 -0
  9. package/lib/entity/company/companyStateTypes.d.ts +11 -0
  10. package/lib/entity/connectedAccount/connectedAccount.d.ts +19 -0
  11. package/lib/entity/connectedAccount/connectedAccount.js +10 -0
  12. package/lib/entity/connectedAccount/connectedAccountPayload.d.ts +11 -0
  13. package/lib/entity/connectedAccount/connectedAccountPayload.js +15 -0
  14. package/lib/entity/connectedAccount/connectedAccountReducer.d.ts +6 -0
  15. package/lib/entity/connectedAccount/connectedAccountReducer.js +27 -0
  16. package/lib/entity/connectedAccount/connectedAccountSelector.d.ts +4 -0
  17. package/lib/entity/connectedAccount/connectedAccountSelector.js +17 -0
  18. package/lib/entity/depositAccount/depositAccount.d.ts +20 -2
  19. package/lib/entity/depositAccount/depositAccountPayload.d.ts +22 -1
  20. package/lib/entity/depositAccount/depositAccountPayload.js +39 -1
  21. package/lib/entity/depositAccount/depositAccountReducer.d.ts +2 -2
  22. package/lib/entity/depositAccount/depositAccountReducer.js +8 -2
  23. package/lib/entity/depositAccount/depositAccountSelector.d.ts +3 -1
  24. package/lib/entity/depositAccount/depositAccountSelector.js +10 -0
  25. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  26. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  27. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  28. package/lib/entity/tenant/clearAllEpic.js +2 -0
  29. package/lib/entity/tenant/tenantSelector.d.ts +5 -1
  30. package/lib/entity/tenant/tenantSelector.js +6 -0
  31. package/lib/epic.d.ts +5 -1
  32. package/lib/epic.js +5 -1
  33. package/lib/index.d.ts +11 -11
  34. package/lib/index.js +21 -13
  35. package/lib/reducer.d.ts +3 -0
  36. package/lib/reducer.js +3 -0
  37. package/lib/view/addressView/__mocks__/json/createCompanyAddressSuccess.json +8 -0
  38. package/lib/view/addressView/__mocks__/json/createCompanyUserAddressSuccess.json +16 -0
  39. package/lib/view/addressView/addressViewState.d.ts +1 -1
  40. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +1 -1
  41. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +1 -1
  42. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingSelector.js +4 -3
  43. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.d.ts +5 -3
  44. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.js +4 -2
  45. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +8 -3
  46. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigState.d.ts +4 -2
  47. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.d.ts +12 -0
  48. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.js +26 -0
  49. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailPayload.d.ts +2 -0
  50. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +43 -4
  51. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +104 -9
  52. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +15 -0
  53. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +70 -16
  54. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.d.ts +2 -1
  55. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +12 -3
  56. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardTransactionListEpic.js +2 -1
  57. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchDepositAccountLimitEpic.d.ts +8 -0
  58. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchDepositAccountLimitEpic.js +41 -0
  59. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateChargeCardLimitEpic.js +2 -2
  60. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateDebitCardPinAttemptEpic.d.ts +11 -0
  61. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateDebitCardPinAttemptEpic.js +42 -0
  62. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +11 -1
  63. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +20 -1
  64. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListPayload.d.ts +16 -1
  65. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +5 -3
  66. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +30 -4
  67. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +5 -2
  68. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +24 -13
  69. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.d.ts +2 -2
  70. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +16 -2
  71. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchDebitCardSummaryEpic.d.ts +7 -0
  72. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchDebitCardSummaryEpic.js +23 -0
  73. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.d.ts +2 -1
  74. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.js +4 -2
  75. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewSelector.d.ts +2 -1
  76. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewSelector.js +2 -0
  77. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/acceptChargeCardTermsEpic.js +19 -2
  78. package/lib/view/spendManagement/chargeCards/issueChargeCard/depositAccountWithLimitPayload.d.ts +6 -0
  79. package/lib/view/spendManagement/chargeCards/issueChargeCard/depositAccountWithLimitPayload.js +2 -0
  80. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchDepositAccountListForCardsEpic.d.ts +8 -0
  81. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchDepositAccountListForCardsEpic.js +31 -0
  82. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchIssueCardPageEpic.d.ts +2 -2
  83. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchIssueCardPageEpic.js +15 -3
  84. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  85. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +65 -25
  86. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +11 -3
  87. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +45 -11
  88. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +6 -3
  89. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +33 -18
  90. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +41 -8
  91. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.js +0 -21
  92. package/lib/view/spendManagement/commonSetup/epic/setup/enableSetupEpic.js +9 -0
  93. package/lib/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +8 -3
  94. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +4 -4
  95. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -1
  96. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +3 -1
  97. package/lib/view/spendManagement/commonSetup/setupViewState.js +13 -1
  98. package/lib/view/spendManagement/helpers.d.ts +3 -0
  99. package/lib/view/spendManagement/helpers.js +13 -1
  100. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/getPaymentAccountsEpic.js +2 -1
  101. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountEpic.js +2 -1
  102. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountLoginStatusEpic.js +2 -1
  103. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountStatusEpic.js +2 -1
  104. package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js +2 -1
  105. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.d.ts +10 -10
  106. package/lib/view/spendManagement/zeniAccounts/checkDeposit/checkDepositSelector.js +1 -1
  107. package/lib/view/spendManagement/zeniAccounts/depositAccountList/depositAccountListSelector.d.ts +1 -1
  108. package/lib/view/spendManagement/zeniAccounts/depositAccountList/depositAccountListSelector.js +3 -3
  109. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.js +1 -1
  110. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.js +1 -1
  111. package/lib/view/spendManagement/zeniAccounts/zeniAccountList/zeniAccountListSelector.js +1 -1
  112. package/lib/view/twoFactorAuthentication/resendOtpEpic.d.ts +3 -2
  113. package/lib/view/twoFactorAuthentication/resendOtpEpic.js +44 -19
  114. package/lib/view/twoFactorAuthentication/sendOtpEpic.d.ts +2 -1
  115. package/lib/view/twoFactorAuthentication/sendOtpEpic.js +45 -18
  116. package/lib/view/twoFactorAuthentication/twoFactorAuthentication.d.ts +17 -5
  117. package/lib/view/twoFactorAuthentication/twoFactorAuthentication.js +33 -0
  118. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationPayload.d.ts +7 -7
  119. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationPayload.js +6 -6
  120. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationReducer.d.ts +22 -6
  121. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationReducer.js +176 -60
  122. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.d.ts +5 -3
  123. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.js +13 -2
  124. package/lib/view/twoFactorAuthentication/verifyOtpEpic.d.ts +5 -2
  125. package/lib/view/twoFactorAuthentication/verifyOtpEpic.js +46 -5
  126. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +2 -2
  127. package/lib/view/userListView/fetchUserListByTypeEpic.js +4 -3
  128. package/lib/view/userListView/userListViewPayload.d.ts +11 -0
  129. package/package.json +1 -1
@@ -10,9 +10,26 @@ const userRoleReducer_1 = require("../../../../../entity/userRole/userRoleReduce
10
10
  const responsePayload_1 = require("../../../../../responsePayload");
11
11
  const chargeCardSetUpViewReducer_1 = require("../chargeCardSetUpViewReducer");
12
12
  const acceptChargeCardTermsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardSetUpViewReducer_1.acceptChargeCardTerms.match), (0, operators_1.mergeMap)((action) => {
13
- const { companyId, enableChargeCard } = action.payload;
13
+ const { companyId, enableChargeCard, chargeCardSetupViewType } = action.payload;
14
+ let payload;
15
+ switch (chargeCardSetupViewType) {
16
+ case 'charge_cards':
17
+ payload = Object.assign({ is_charge_cards_tos_accepted: true }, (enableChargeCard && { is_charge_cards_enabled: true }));
18
+ break;
19
+ case 'charge_cards__debit_cards':
20
+ payload = Object.assign({ is_charge_cards_tos_accepted: true, is_debit_cards_tos_accepted: true }, (enableChargeCard && {
21
+ is_charge_cards_enabled: true,
22
+ is_debit_cards_enabled: true,
23
+ }));
24
+ break;
25
+ case 'debit_cards':
26
+ payload = Object.assign({ is_debit_cards_tos_accepted: true }, (enableChargeCard && { is_debit_cards_enabled: true }));
27
+ break;
28
+ default:
29
+ payload = {};
30
+ }
14
31
  return zeniAPI
15
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, Object.assign({ is_charge_cards_tos_accepted: true }, (enableChargeCard && { is_charge_cards_enabled: true })))
32
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
16
33
  .pipe((0, operators_1.mergeMap)((response) => {
17
34
  if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
18
35
  const actions = [
@@ -0,0 +1,6 @@
1
+ import { DepositAccountWithLimitPayload } from '../../../../entity/depositAccount/depositAccountPayload';
2
+ import { ZeniAPIResponse } from '../../../../responsePayload';
3
+ export interface FetchDepositAccountsForCardsPayload {
4
+ deposit_accounts: DepositAccountWithLimitPayload[];
5
+ }
6
+ export type FetchDepositAccountsForCardsResponse = ZeniAPIResponse<FetchDepositAccountsForCardsPayload>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateDepositAccountLimitsForChargeCard } from '../../../../entity/depositAccount/depositAccountReducer';
4
+ import { RootState } from '../../../../reducer';
5
+ import { ZeniAPI } from '../../../../zeniAPI';
6
+ import { fetchDepositAccountListForCards, updateDepositAccountListForCardsFetchStatus, updateDepositAccountsInCards } from './issueChargeCardReducer';
7
+ export type ActionType = ReturnType<typeof fetchDepositAccountListForCards> | ReturnType<typeof updateDepositAccountsInCards> | ReturnType<typeof updateDepositAccountLimitsForChargeCard> | ReturnType<typeof updateDepositAccountListForCardsFetchStatus>;
8
+ export declare const fetchDepositAccountListForCardsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchDepositAccountListForCardsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const depositAccountReducer_1 = require("../../../../entity/depositAccount/depositAccountReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const issueChargeCardReducer_1 = require("./issueChargeCardReducer");
9
+ const fetchDepositAccountListForCardsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(issueChargeCardReducer_1.fetchDepositAccountListForCards.match), (0, operators_1.switchMap)(() => {
10
+ return zeniAPI
11
+ .getJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/limits`)
12
+ .pipe((0, operators_1.mergeMap)((response) => {
13
+ var _a, _b, _c, _d;
14
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
15
+ return (0, rxjs_1.of)((0, issueChargeCardReducer_1.updateDepositAccountsInCards)((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.deposit_accounts) !== null && _b !== void 0 ? _b : []), (0, depositAccountReducer_1.updateDepositAccountLimitsForChargeCard)((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.deposit_accounts) !== null && _d !== void 0 ? _d : []));
16
+ }
17
+ else {
18
+ return (0, rxjs_1.of)((0, issueChargeCardReducer_1.updateDepositAccountListForCardsFetchStatus)({
19
+ fetchState: 'Error',
20
+ error: response.status,
21
+ }));
22
+ }
23
+ }), (0, operators_1.catchError)((error) => {
24
+ return (0, rxjs_1.of)((0, issueChargeCardReducer_1.updateDepositAccountListForCardsFetchStatus)({
25
+ fetchState: 'Error',
26
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch deposit Accounts For Cards REST API call errored out' +
27
+ JSON.stringify(error)),
28
+ }));
29
+ }));
30
+ }));
31
+ exports.fetchDepositAccountListForCardsEpic = fetchDepositAccountListForCardsEpic;
@@ -5,6 +5,6 @@ import { fetchClassList } from '../../../classList/classListReducer';
5
5
  import { fetchUserListByType } from '../../../userListView/userListViewReducer';
6
6
  import { fetchChargeCardConfig } from '../chargeCardConfig/chargeCardConfigReducer';
7
7
  import { fetchChargeCardList, fetchCreditAccount } from '../chargeCardList/chargeCardListReducer';
8
- import { fetchIssueCardPage } from './issueChargeCardReducer';
9
- export type ActionType = ReturnType<typeof fetchIssueCardPage> | ReturnType<typeof fetchChargeCardConfig> | ReturnType<typeof fetchUserListByType> | ReturnType<typeof fetchChargeCardList> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchCreditAccount>;
8
+ import { fetchDepositAccountListForCards, fetchIssueCardPage } from './issueChargeCardReducer';
9
+ export type ActionType = ReturnType<typeof fetchIssueCardPage> | ReturnType<typeof fetchChargeCardConfig> | ReturnType<typeof fetchUserListByType> | ReturnType<typeof fetchDepositAccountListForCards> | ReturnType<typeof fetchChargeCardList> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchCreditAccount>;
10
10
  export declare const fetchIssueCardPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -9,15 +9,20 @@ const chargeCardConfigReducer_1 = require("../chargeCardConfig/chargeCardConfigR
9
9
  const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
10
10
  const issueChargeCardReducer_1 = require("./issueChargeCardReducer");
11
11
  const fetchIssueCardPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(issueChargeCardReducer_1.fetchIssueCardPage.match), (0, operators_1.mergeMap)((action) => {
12
- const { cacheOverride } = action.payload;
12
+ const { cacheOverride, isDebitCardFlagEnabled, isCreditCardFlagEnabled } = action.payload;
13
13
  const issueCardPageAction = [];
14
14
  const state = state$.value;
15
15
  if (cacheOverride === true) {
16
16
  issueCardPageAction.push((0, chargeCardConfigReducer_1.fetchChargeCardConfig)());
17
- issueCardPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
17
+ if (isCreditCardFlagEnabled) {
18
+ issueCardPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
19
+ }
18
20
  issueCardPageAction.push((0, userListViewReducer_1.fetchUserListByType)('cardHolderCandidate', true));
19
21
  issueCardPageAction.push((0, classListReducer_1.fetchClassList)());
20
22
  issueCardPageAction.push((0, chargeCardListReducer_1.fetchChargeCardList)());
23
+ if (isDebitCardFlagEnabled) {
24
+ issueCardPageAction.push((0, issueChargeCardReducer_1.fetchDepositAccountListForCards)());
25
+ }
21
26
  }
22
27
  else {
23
28
  const chargeCardConfig = state.chargeCardConfigState;
@@ -27,7 +32,8 @@ const fetchIssueCardPageEpic = (actions$, state$) => actions$.pipe((0, operators
27
32
  }
28
33
  const chargeCardList = state.chargeCardListState;
29
34
  if (chargeCardList.creditAccount.fetchState !== 'Completed' &&
30
- chargeCardList.creditAccount.fetchState !== 'In-Progress') {
35
+ chargeCardList.creditAccount.fetchState !== 'In-Progress' &&
36
+ isCreditCardFlagEnabled) {
31
37
  issueCardPageAction.push((0, chargeCardListReducer_1.fetchCreditAccount)());
32
38
  }
33
39
  const userList = state.userListViewState.userListByType.cardHolderCandidate;
@@ -43,6 +49,12 @@ const fetchIssueCardPageEpic = (actions$, state$) => actions$.pipe((0, operators
43
49
  chargeCardList.fetchState !== 'In-Progress') {
44
50
  issueCardPageAction.push((0, chargeCardListReducer_1.fetchChargeCardList)());
45
51
  }
52
+ const depositAccountsFetchState = state.issueChargeCardState.depositAccountsFetchState;
53
+ if (isDebitCardFlagEnabled &&
54
+ depositAccountsFetchState.fetchState !== 'Completed' &&
55
+ depositAccountsFetchState.fetchState !== 'In-Progress') {
56
+ issueCardPageAction.push((0, issueChargeCardReducer_1.fetchDepositAccountListForCards)());
57
+ }
46
58
  }
47
59
  return (0, rxjs_1.concat)((0, rxjs_1.from)(issueCardPageAction));
48
60
  }));
@@ -8,6 +8,6 @@ import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
8
8
  import { RootState } from '../../../../reducer';
9
9
  import { ZeniAPI } from '../../../../zeniAPI';
10
10
  import { updateChargeCardList } from '../chargeCardList/chargeCardListReducer';
11
- import { issueChargeCardSuccessOrFailure, issueChargeCards, updateCardCount } from './issueChargeCardReducer';
12
- export type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateCardCount> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
11
+ import { issueChargeCardSuccessOrFailure, issueChargeCards, updateChargeCardCount, updateDebitCardCount } from './issueChargeCardReducer';
12
+ export type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
13
13
  export declare const issueChargeCardEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -15,42 +15,82 @@ const issueChargeCardEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
15
15
  const state = state$.value;
16
16
  const localData = state.issueChargeCardState.localData;
17
17
  const payload = localData.map((data) => {
18
- var _a, _b, _c, _d, _e, _f, _g, _h;
19
- if (data.cardType === 'business_physical_credit_card') {
20
- return {
21
- card_holder_user_ids: data.physicalCard.userId != null
22
- ? [data.physicalCard.userId]
23
- : [],
24
- card_name: data.physicalCard.cardName,
25
- credit_limit: (_b = (_a = data.physicalCard.amount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
26
- currency_code: (_d = (_c = data.physicalCard.amount) === null || _c === void 0 ? void 0 : _c.currencyCode) !== null && _d !== void 0 ? _d : 'USD',
27
- credit_limit_frequency: { code: data.physicalCard.frequency },
28
- card_type: data.cardType,
29
- shipping_address_type: data.physicalCard.addressType,
30
- shipping_address_id: data.physicalCard.addressId,
31
- };
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
19
+ if (data.chargeCardType === 'credit_card') {
20
+ if (data.creditCard.cardType === 'business_physical_credit_card') {
21
+ return {
22
+ card_holder_user_ids: data.creditCard.physicalCard.userId != null
23
+ ? [data.creditCard.physicalCard.userId]
24
+ : [],
25
+ card_name: data.creditCard.physicalCard.cardName,
26
+ purchase_limit: (_b = (_a = data.creditCard.physicalCard.amount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
27
+ currency_code: (_d = (_c = data.creditCard.physicalCard.amount) === null || _c === void 0 ? void 0 : _c.currencyCode) !== null && _d !== void 0 ? _d : 'USD',
28
+ purchase_limit_frequency: {
29
+ code: data.creditCard.physicalCard.frequency,
30
+ },
31
+ card_type: data.creditCard.cardType,
32
+ shipping_address_type: data.creditCard.physicalCard.addressType,
33
+ shipping_address_id: data.creditCard.physicalCard.addressId,
34
+ };
35
+ }
36
+ {
37
+ return {
38
+ card_holder_user_ids: data.creditCard.virtualCard.userIds,
39
+ card_name: data.creditCard.virtualCard.cardName,
40
+ purchase_limit: (_f = (_e = data.creditCard.virtualCard.amount) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0,
41
+ currency_code: (_h = (_g = data.creditCard.virtualCard.amount) === null || _g === void 0 ? void 0 : _g.currencyCode) !== null && _h !== void 0 ? _h : 'USD',
42
+ purchase_limit_frequency: {
43
+ code: data.creditCard.virtualCard.frequency,
44
+ },
45
+ card_type: data.creditCard.cardType,
46
+ };
47
+ }
32
48
  }
33
49
  else {
34
- return {
35
- card_holder_user_ids: data.virtualCard.userIds,
36
- card_name: data.virtualCard.cardName,
37
- credit_limit: (_f = (_e = data.virtualCard.amount) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0,
38
- currency_code: (_h = (_g = data.virtualCard.amount) === null || _g === void 0 ? void 0 : _g.currencyCode) !== null && _h !== void 0 ? _h : 'USD',
39
- credit_limit_frequency: { code: data.virtualCard.frequency },
40
- card_type: data.cardType,
41
- };
50
+ if (data.debitCard.cardType === 'business_physical_debit_card') {
51
+ return {
52
+ card_holder_user_ids: data.debitCard.physicalCard.userId != null
53
+ ? [data.debitCard.physicalCard.userId]
54
+ : [],
55
+ card_name: data.debitCard.physicalCard.cardName,
56
+ purchase_limit: (_k = (_j = data.debitCard.physicalCard.amount) === null || _j === void 0 ? void 0 : _j.amount) !== null && _k !== void 0 ? _k : 0,
57
+ currency_code: (_m = (_l = data.debitCard.physicalCard.amount) === null || _l === void 0 ? void 0 : _l.currencyCode) !== null && _m !== void 0 ? _m : 'USD',
58
+ purchase_limit_frequency: {
59
+ code: data.debitCard.physicalCard.frequency,
60
+ },
61
+ card_type: data.debitCard.cardType,
62
+ shipping_address_type: data.debitCard.physicalCard.addressType,
63
+ shipping_address_id: data.debitCard.physicalCard.addressId,
64
+ connected_account_id: data.debitCard.physicalCard.connectedAccountId,
65
+ connected_account_type: 'deposit_account',
66
+ };
67
+ }
68
+ else {
69
+ return {
70
+ card_holder_user_ids: data.debitCard.virtualCard.userIds,
71
+ card_name: data.debitCard.virtualCard.cardName,
72
+ purchase_limit: (_p = (_o = data.debitCard.virtualCard.amount) === null || _o === void 0 ? void 0 : _o.amount) !== null && _p !== void 0 ? _p : 0,
73
+ currency_code: (_r = (_q = data.debitCard.virtualCard.amount) === null || _q === void 0 ? void 0 : _q.currencyCode) !== null && _r !== void 0 ? _r : 'USD',
74
+ purchase_limit_frequency: {
75
+ code: data.debitCard.virtualCard.frequency,
76
+ },
77
+ connected_account_id: data.debitCard.virtualCard.connectedAccountId,
78
+ card_type: data.debitCard.cardType,
79
+ connected_account_type: 'deposit_account',
80
+ };
81
+ }
42
82
  }
43
83
  });
44
84
  return zeniAPI
45
85
  .postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`, { cards: payload })
46
86
  .pipe((0, operators_1.mergeMap)((response) => {
47
- var _a, _b, _c;
87
+ var _a, _b, _c, _d, _e;
48
88
  if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
49
89
  const actions = [];
50
90
  actions.push((0, chargeCardReducer_1.updateChargeCards)(response.data.cards), (0, userReducer_1.updateAllUsers)({ users: response.data.users }), (0, userRoleReducer_1.updateUserRoles)(response.data.user_roles), (0, chargeCardListReducer_1.updateChargeCardList)({
51
91
  chargeCardListPayload: response.data,
52
92
  keepExistingListItems: true,
53
- }), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.updateCardCount)((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.cards_count_by_user_id) !== null && _b !== void 0 ? _b : []), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
93
+ }), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.updateChargeCardCount)((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.cards_count_by_user_id) !== null && _b !== void 0 ? _b : []), (0, issueChargeCardReducer_1.updateDebitCardCount)((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.debit_cards_count_by_deposit_account_id) !== null && _d !== void 0 ? _d : {}), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
54
94
  const cardHolderIds = response.data.cards.map((card) => card.holder_user_id);
55
95
  const namesList = response.data.users
56
96
  .filter((user) => cardHolderIds.includes(user.user_id))
@@ -65,7 +105,7 @@ const issueChargeCardEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
65
105
  variables: [
66
106
  {
67
107
  variableName: '_user-name_',
68
- variableValue: (_c = namesList[0]) !== null && _c !== void 0 ? _c : '',
108
+ variableValue: (_e = namesList[0]) !== null && _e !== void 0 ? _e : '',
69
109
  },
70
110
  {
71
111
  variableName: '_card_',
@@ -1,6 +1,8 @@
1
1
  import { FetchState, ID } from '../../../../commonStateTypes/common';
2
+ import { CardCodeType } from '../../../../entity/chargeCard/chargeCard';
3
+ import { DepositAccountWithLimitPayload } from '../../../../entity/depositAccount/depositAccountPayload';
2
4
  import { ZeniAPIStatus } from '../../../../responsePayload';
3
- import { ActiveChargeCardCountPayload } from '../../../userListView/userListViewPayload';
5
+ import { ActiveChargeCardCountPayload, ActiveDebitCardCountByUserIdPayload } from '../../../userListView/userListViewPayload';
4
6
  import { IssueChargeCardLocalData, IssueChargeCardState } from './issueChargeCardState';
5
7
  export declare const initialState: IssueChargeCardState;
6
8
  export declare const issueChargeCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[], {}, "issueChargeCard/issueChargeCards", never, never>, updateChargeCardsLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<IssueChargeCardLocalData[], "issueChargeCard/updateChargeCardsLocalStore">, issueChargeCardSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
@@ -9,8 +11,14 @@ export declare const issueChargeCards: import("@reduxjs/toolkit").ActionCreatorW
9
11
  }, "issueChargeCard/issueChargeCardSuccessOrFailure">, resetIssueChargeCardForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/resetIssueChargeCardForm">, updateCustomAddressId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
12
  addressId: ID;
11
13
  cardLineId: ID;
12
- }, "issueChargeCard/updateCustomAddressId">, updateCardCount: import("@reduxjs/toolkit").ActionCreatorWithPayload<ActiveChargeCardCountPayload[], "issueChargeCard/updateCardCount">, fetchIssueCardPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
14
+ cardType: CardCodeType;
15
+ }, "issueChargeCard/updateCustomAddressId">, updateChargeCardCount: import("@reduxjs/toolkit").ActionCreatorWithPayload<ActiveChargeCardCountPayload[], "issueChargeCard/updateChargeCardCount">, updateDebitCardCount: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<string, ActiveDebitCardCountByUserIdPayload>, "issueChargeCard/updateDebitCardCount">, fetchIssueCardPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[isDebitCardFlagEnabled: boolean, isCreditCardFlagEnabled: boolean, cacheOverride?: any], {
16
+ isDebitCardFlagEnabled: boolean;
17
+ isCreditCardFlagEnabled: boolean;
13
18
  cacheOverride: any;
14
- }, "issueChargeCard/fetchIssueCardPage", never, never>, clearIssueChargeCard: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/clearIssueChargeCard">;
19
+ }, "issueChargeCard/fetchIssueCardPage", never, never>, updateDepositAccountsInCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<DepositAccountWithLimitPayload[], "issueChargeCard/updateDepositAccountsInCards">, fetchDepositAccountListForCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/fetchDepositAccountListForCards">, updateDepositAccountListForCardsFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
20
+ fetchState: FetchState;
21
+ error?: ZeniAPIStatus;
22
+ }, "issueChargeCard/updateDepositAccountListForCardsFetchStatus">, clearIssueChargeCard: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/clearIssueChargeCard">;
15
23
  declare const _default: import("redux").Reducer<IssueChargeCardState>;
16
24
  export default _default;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearIssueChargeCard = exports.fetchIssueCardPage = exports.updateCardCount = exports.updateCustomAddressId = exports.resetIssueChargeCardForm = exports.issueChargeCardSuccessOrFailure = exports.updateChargeCardsLocalStore = exports.issueChargeCards = exports.initialState = void 0;
4
+ exports.clearIssueChargeCard = exports.updateDepositAccountListForCardsFetchStatus = exports.fetchDepositAccountListForCards = exports.updateDepositAccountsInCards = exports.fetchIssueCardPage = exports.updateDebitCardCount = exports.updateChargeCardCount = exports.updateCustomAddressId = exports.resetIssueChargeCardForm = exports.issueChargeCardSuccessOrFailure = exports.updateChargeCardsLocalStore = exports.issueChargeCards = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
- const issueChargeCardState_1 = require("./issueChargeCardState");
7
6
  exports.initialState = {
8
- localData: issueChargeCardState_1.initialIssueChargeCardLocalData,
7
+ depositAccountIds: [],
8
+ depositAccountsFetchState: { fetchState: 'Not-Started', error: undefined },
9
+ localData: [],
9
10
  fetchState: 'Not-Started',
10
11
  error: undefined,
11
12
  saveStatus: {
@@ -15,7 +16,8 @@ exports.initialState = {
15
16
  hasValidState() {
16
17
  return this.fetchState == 'Completed';
17
18
  },
18
- activeCardCount: {},
19
+ activeChargeCardCount: {},
20
+ activeDebitCardCountByDepositAccountId: {},
19
21
  };
20
22
  const issueChargeCard = (0, toolkit_1.createSlice)({
21
23
  name: 'issueChargeCard',
@@ -25,9 +27,13 @@ const issueChargeCard = (0, toolkit_1.createSlice)({
25
27
  reducer() {
26
28
  //do nothing
27
29
  },
28
- prepare(cacheOverride = false) {
30
+ prepare(isDebitCardFlagEnabled, isCreditCardFlagEnabled, cacheOverride = false) {
29
31
  return {
30
- payload: { cacheOverride },
32
+ payload: {
33
+ isDebitCardFlagEnabled,
34
+ isCreditCardFlagEnabled,
35
+ cacheOverride,
36
+ },
31
37
  };
32
38
  },
33
39
  },
@@ -52,24 +58,52 @@ const issueChargeCard = (0, toolkit_1.createSlice)({
52
58
  draft.saveStatus.error = action.payload.error;
53
59
  },
54
60
  updateCustomAddressId(draft, action) {
55
- const { addressId, cardLineId } = action.payload;
61
+ const { addressId, cardLineId, cardType } = action.payload;
56
62
  const targetIndex = draft.localData.findIndex((lineItem) => lineItem.lineId === cardLineId);
57
63
  if (targetIndex > -1) {
58
- draft.localData[targetIndex] = Object.assign(Object.assign({}, draft.localData[targetIndex]), { physicalCard: Object.assign(Object.assign({}, draft.localData[targetIndex].physicalCard), { addressId: addressId }) });
64
+ if (cardType === 'business_physical_credit_card') {
65
+ draft.localData[targetIndex] = Object.assign(Object.assign({}, draft.localData[targetIndex]), { creditCard: Object.assign(Object.assign({}, draft.localData[targetIndex].creditCard), { physicalCard: Object.assign(Object.assign({}, draft.localData[targetIndex].creditCard.physicalCard), { addressId: addressId }) }) });
66
+ }
67
+ else if (cardType === 'business_physical_debit_card') {
68
+ draft.localData[targetIndex] = Object.assign(Object.assign({}, draft.localData[targetIndex]), { debitCard: Object.assign(Object.assign({}, draft.localData[targetIndex].debitCard), { physicalCard: Object.assign(Object.assign({}, draft.localData[targetIndex].debitCard.physicalCard), { addressId: addressId }) }) });
69
+ }
59
70
  }
60
71
  },
61
- updateCardCount(draft, action) {
72
+ updateChargeCardCount(draft, action) {
62
73
  action.payload.forEach((activeChargeCardCountPayload) => {
63
- draft.activeCardCount[activeChargeCardCountPayload.user_id] = {
74
+ draft.activeChargeCardCount[activeChargeCardCountPayload.user_id] = {
64
75
  physicalCardCount: activeChargeCardCountPayload.business_physical_credit_card_count,
65
76
  virtualCardCount: activeChargeCardCountPayload.business_virtual_credit_card_count,
66
77
  };
67
78
  });
68
79
  },
80
+ updateDebitCardCount(draft, action) {
81
+ Object.entries(action.payload).forEach(([depositAccountId, activeDebitCardCountByUserIdPayload]) => {
82
+ Object.entries(activeDebitCardCountByUserIdPayload).forEach(([userId, activeDebitCardCount]) => {
83
+ draft.activeDebitCardCountByDepositAccountId = Object.assign(Object.assign({}, draft.activeDebitCardCountByDepositAccountId), { [depositAccountId]: Object.assign(Object.assign({}, draft.activeDebitCardCountByDepositAccountId[depositAccountId]), { [userId]: {
84
+ physicalCardCount: activeDebitCardCount.business_physical_debit_card_count,
85
+ virtualCardCount: activeDebitCardCount.business_virtual_debit_card_count,
86
+ } }) });
87
+ });
88
+ });
89
+ },
90
+ fetchDepositAccountListForCards(draft) {
91
+ draft.depositAccountsFetchState.error = undefined;
92
+ draft.depositAccountsFetchState.fetchState = 'In-Progress';
93
+ },
94
+ updateDepositAccountsInCards(draft, action) {
95
+ draft.depositAccountIds = action.payload.map((depositAccountWithLimitPayload) => depositAccountWithLimitPayload.deposit_account_id);
96
+ draft.depositAccountsFetchState.fetchState = 'Completed';
97
+ draft.depositAccountsFetchState.error = undefined;
98
+ },
99
+ updateDepositAccountListForCardsFetchStatus(draft, action) {
100
+ draft.depositAccountsFetchState.fetchState = action.payload.fetchState;
101
+ draft.depositAccountsFetchState.error = action.payload.error;
102
+ },
69
103
  clearIssueChargeCard(draft) {
70
104
  Object.assign(draft, exports.initialState);
71
105
  },
72
106
  },
73
107
  });
74
- _a = issueChargeCard.actions, exports.issueChargeCards = _a.issueChargeCards, exports.updateChargeCardsLocalStore = _a.updateChargeCardsLocalStore, exports.issueChargeCardSuccessOrFailure = _a.issueChargeCardSuccessOrFailure, exports.resetIssueChargeCardForm = _a.resetIssueChargeCardForm, exports.updateCustomAddressId = _a.updateCustomAddressId, exports.updateCardCount = _a.updateCardCount, exports.fetchIssueCardPage = _a.fetchIssueCardPage, exports.clearIssueChargeCard = _a.clearIssueChargeCard;
108
+ _a = issueChargeCard.actions, exports.issueChargeCards = _a.issueChargeCards, exports.updateChargeCardsLocalStore = _a.updateChargeCardsLocalStore, exports.issueChargeCardSuccessOrFailure = _a.issueChargeCardSuccessOrFailure, exports.resetIssueChargeCardForm = _a.resetIssueChargeCardForm, exports.updateCustomAddressId = _a.updateCustomAddressId, exports.updateChargeCardCount = _a.updateChargeCardCount, exports.updateDebitCardCount = _a.updateDebitCardCount, exports.fetchIssueCardPage = _a.fetchIssueCardPage, exports.updateDepositAccountsInCards = _a.updateDepositAccountsInCards, exports.fetchDepositAccountListForCards = _a.fetchDepositAccountListForCards, exports.updateDepositAccountListForCardsFetchStatus = _a.updateDepositAccountListForCardsFetchStatus, exports.clearIssueChargeCard = _a.clearIssueChargeCard;
75
109
  exports.default = issueChargeCard.reducer;
@@ -2,22 +2,25 @@ import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { Address } from '../../../../entity/address/addressState';
4
4
  import { Class } from '../../../../entity/class/classState';
5
+ import { DepositAccountWithLimit } from '../../../../entity/depositAccount/depositAccount';
5
6
  import { RootState } from '../../../../reducer';
6
7
  import { Person } from '../../../people/peopleSelectorTypes';
7
8
  import { ChargeCardConfigState } from '../chargeCardConfig/chargeCardConfigState';
8
9
  import { CreditAccount } from '../chargeCardList/chargeCardList';
9
- import { ActiveChargeCardCount, IssueChargeCardLocalData } from './issueChargeCardState';
10
+ import { ActiveChargeCardCount, ActiveDebitCardCountByUserId, IssueChargeCardLocalData } from './issueChargeCardState';
10
11
  export interface IssueChargeCardSelectorView extends SelectorView {
11
12
  localData: IssueChargeCardLocalData[];
12
13
  issueCardStatus: FetchStateAndError;
13
14
  userList: Person[];
15
+ depositAccounts: DepositAccountWithLimit[];
14
16
  allAccountingClasses: Class[];
15
17
  chargeCardConfig: ChargeCardConfigState;
16
18
  creditAccount: CreditAccount;
17
19
  customAddress: Record<ID, Address>;
18
20
  customAddressStatus: Record<ID, FetchStateAndError>;
19
21
  userAddress: Record<ID, Address>;
20
- activeCardCountByUser: Record<ID, ActiveChargeCardCount>;
22
+ activeChargeCardCount: Record<ID, ActiveChargeCardCount>;
23
+ activeDebitCardCountByDepositAccountId: Record<ID, ActiveDebitCardCountByUserId>;
21
24
  companyAddress?: Address;
22
25
  }
23
- export declare const getIssueChargeCardView: (state: RootState) => IssueChargeCardSelectorView;
26
+ export declare const getIssueChargeCardView: (state: RootState, isCreditCardEnabled: boolean, isDebitCardEnabled: boolean) => IssueChargeCardSelectorView;
@@ -4,14 +4,16 @@ exports.getIssueChargeCardView = void 0;
4
4
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
5
5
  const addressSelector_1 = require("../../../../entity/address/addressSelector");
6
6
  const classSelector_1 = require("../../../../entity/class/classSelector");
7
+ const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
7
8
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
9
  const addressViewSelector_1 = require("../../../addressView/addressViewSelector");
9
10
  const userListViewSelector_1 = require("../../../userListView/userListViewSelector");
10
- const getIssueChargeCardView = (state) => {
11
+ const getIssueChargeCardView = (state, isCreditCardEnabled, isDebitCardEnabled) => {
11
12
  var _a;
12
- const { issueChargeCardState, userState, userRoleState, userListViewState, chargeCardConfigState, chargeCardListState, addressState, classState, classListState, } = state;
13
+ const { issueChargeCardState, userState, userRoleState, userListViewState, chargeCardConfigState, chargeCardListState, addressState, classState, depositAccountState, classListState, } = state;
13
14
  const userListSelectorView = (0, userListViewSelector_1.getUserList)(userState, userRoleState, userListViewState, 'cardHolderCandidate');
14
15
  const userList = userListSelectorView.users;
16
+ const depositAccounts = (0, depositAccountSelector_1.getDepositAccountLimitsForChargeCardByDepositAccountIds)(depositAccountState, issueChargeCardState.depositAccountIds);
15
17
  let selectedUserAddress = {};
16
18
  userList.forEach((user) => {
17
19
  var _a, _b;
@@ -31,17 +33,23 @@ const getIssueChargeCardView = (state) => {
31
33
  };
32
34
  issueChargeCardState.localData.forEach((lineItem) => {
33
35
  var _a;
34
- if (lineItem.cardType === 'business_physical_credit_card') {
35
- const targetLineId = lineItem.lineId;
36
- const newlyAddedAddress = (0, addressViewSelector_1.getNewAddress)(`custom_shipping_${targetLineId}_address`, state);
37
- customAddressStatus = Object.assign(Object.assign({}, customAddressStatus), { [targetLineId]: (_a = newlyAddedAddress === null || newlyAddedAddress === void 0 ? void 0 : newlyAddedAddress.status) !== null && _a !== void 0 ? _a : defaultFetchState });
38
- if (newlyAddedAddress != null &&
39
- newlyAddedAddress.status.fetchState === 'Completed' &&
40
- newlyAddedAddress.newAddressId != null) {
41
- const addressFromEntity = (0, addressSelector_1.getAddressByAddressId)(addressState, newlyAddedAddress.newAddressId);
42
- if (addressFromEntity != null) {
43
- customAddress = Object.assign(Object.assign({}, customAddress), { [targetLineId]: addressFromEntity });
44
- }
36
+ let newlyAddedAddress;
37
+ const targetLineId = lineItem.lineId;
38
+ if (lineItem.chargeCardType === 'credit_card' &&
39
+ lineItem.creditCard.cardType === 'business_physical_credit_card') {
40
+ newlyAddedAddress = (0, addressViewSelector_1.getNewAddress)(`credit_custom_shipping_${targetLineId}_address`, state);
41
+ }
42
+ else if (lineItem.chargeCardType === 'debit_card' &&
43
+ lineItem.debitCard.cardType === 'business_physical_debit_card') {
44
+ newlyAddedAddress = (0, addressViewSelector_1.getNewAddress)(`debit_custom_shipping_${targetLineId}_address`, state);
45
+ }
46
+ customAddressStatus = Object.assign(Object.assign({}, customAddressStatus), { [targetLineId]: (_a = newlyAddedAddress === null || newlyAddedAddress === void 0 ? void 0 : newlyAddedAddress.status) !== null && _a !== void 0 ? _a : defaultFetchState });
47
+ if (newlyAddedAddress != null &&
48
+ newlyAddedAddress.status.fetchState === 'Completed' &&
49
+ newlyAddedAddress.newAddressId != null) {
50
+ const addressFromEntity = (0, addressSelector_1.getAddressByAddressId)(addressState, newlyAddedAddress.newAddressId);
51
+ if (addressFromEntity != null) {
52
+ customAddress = Object.assign(Object.assign({}, customAddress), { [targetLineId]: addressFromEntity });
45
53
  }
46
54
  }
47
55
  });
@@ -50,20 +58,26 @@ const getIssueChargeCardView = (state) => {
50
58
  classIds: classIds,
51
59
  reportId: 'class_list',
52
60
  });
53
- const issueCardPageFetchState = (0, reduceFetchState_1.reduceFetchState)([
61
+ const requiredFetchStates = [
54
62
  chargeCardConfigState,
55
63
  userListViewState.userListByType.cardHolderCandidate,
56
64
  userListSelectorView,
57
- chargeCardListState.creditAccount,
58
65
  classListState,
59
- chargeCardListState,
60
- ]);
66
+ ];
67
+ if (isDebitCardEnabled) {
68
+ requiredFetchStates.push(issueChargeCardState.depositAccountsFetchState);
69
+ }
70
+ if (isCreditCardEnabled) {
71
+ requiredFetchStates.push(chargeCardListState.creditAccount);
72
+ }
73
+ const issueCardPageFetchState = (0, reduceFetchState_1.reduceFetchState)(requiredFetchStates);
61
74
  return {
62
75
  fetchState: issueCardPageFetchState.fetchState,
63
76
  error: issueCardPageFetchState.error,
64
77
  issueCardStatus: issueChargeCardState.saveStatus,
65
78
  localData: issueChargeCardState.localData,
66
79
  userList,
80
+ depositAccounts,
67
81
  chargeCardConfig: chargeCardConfigState,
68
82
  creditAccount: chargeCardListState.creditAccount,
69
83
  companyAddress: companyAddress,
@@ -71,7 +85,8 @@ const getIssueChargeCardView = (state) => {
71
85
  customAddressStatus,
72
86
  userAddress: selectedUserAddress,
73
87
  allAccountingClasses,
74
- activeCardCountByUser: issueChargeCardState.activeCardCount,
88
+ activeChargeCardCount: issueChargeCardState.activeChargeCardCount,
89
+ activeDebitCardCountByDepositAccountId: issueChargeCardState.activeDebitCardCountByDepositAccountId,
75
90
  };
76
91
  };
77
92
  exports.getIssueChargeCardView = getIssueChargeCardView;
@@ -1,33 +1,66 @@
1
1
  import { Amount } from '../../../../commonStateTypes/amount';
2
2
  import { FetchStateAndError, FetchedState, ID } from '../../../../commonStateTypes/common';
3
- import { CardCodeType, CreditLimitFrequencyCodeType, ShippingAddressType } from '../../../../entity/chargeCard/chargeCard';
3
+ import { ChargeCardType, CreditCardCodeType, CreditLimitFrequencyCodeType, DebitCardCodeType, ShippingAddressType } from '../../../../entity/chargeCard/chargeCard';
4
4
  export interface IssueChargeCardState extends FetchedState {
5
5
  localData: IssueChargeCardLocalData[];
6
6
  saveStatus: FetchStateAndError;
7
- activeCardCount: Record<ID, ActiveChargeCardCount>;
7
+ activeChargeCardCount: Record<ID, ActiveChargeCardCount>;
8
+ activeDebitCardCountByDepositAccountId: Record<ID, ActiveDebitCardCountByUserId>;
9
+ depositAccountIds: ID[];
10
+ depositAccountsFetchState: FetchStateAndError;
8
11
  }
9
12
  export interface ActiveChargeCardCount {
10
13
  physicalCardCount: number;
11
14
  virtualCardCount: number;
12
15
  }
13
- export interface PhysicalCardData {
16
+ export interface ActiveDebitCardCountByUserId {
17
+ [userId: ID]: ActiveDebitCardCount;
18
+ }
19
+ export interface ActiveDebitCardCount {
20
+ physicalCardCount: number;
21
+ virtualCardCount: number;
22
+ }
23
+ export interface PhysicalCreditCardData {
24
+ cardName: string;
25
+ frequency: CreditLimitFrequencyCodeType;
26
+ addressType?: ShippingAddressType;
27
+ addressId?: ID;
28
+ amount?: Amount;
29
+ userId?: ID;
30
+ }
31
+ export interface VirtualCreditCardData {
32
+ userIds: ID[];
33
+ cardName: string;
34
+ frequency: CreditLimitFrequencyCodeType;
35
+ amount?: Amount;
36
+ }
37
+ export interface PhysicalDebitCardData {
14
38
  cardName: string;
15
39
  frequency: CreditLimitFrequencyCodeType;
16
40
  addressType?: ShippingAddressType;
17
41
  addressId?: ID;
18
42
  amount?: Amount;
19
43
  userId?: ID;
44
+ connectedAccountId?: ID;
20
45
  }
21
- export interface VirtualCardData {
46
+ export interface VirtualDebitCardData {
22
47
  userIds: ID[];
23
48
  cardName: string;
24
49
  frequency: CreditLimitFrequencyCodeType;
25
50
  amount?: Amount;
51
+ connectedAccountId?: ID;
26
52
  }
27
53
  export interface IssueChargeCardLocalData {
28
54
  lineId: ID;
29
- cardType: CardCodeType;
30
- physicalCard: PhysicalCardData;
31
- virtualCard: VirtualCardData;
55
+ chargeCardType: ChargeCardType;
56
+ creditCard: {
57
+ cardType: CreditCardCodeType;
58
+ physicalCard: PhysicalCreditCardData;
59
+ virtualCard: VirtualCreditCardData;
60
+ };
61
+ debitCard: {
62
+ cardType: DebitCardCodeType;
63
+ physicalCard: PhysicalDebitCardData;
64
+ virtualCard: VirtualDebitCardData;
65
+ };
32
66
  }
33
- export declare const initialIssueChargeCardLocalData: IssueChargeCardLocalData[];