udp-react-enterprise-component-library 26.5.0-beta.12 → 26.5.0-beta.13
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/dist/.tsbuildinfo +1 -1
- package/dist/utilities/form/paymentForm/BankAccountForm.d.ts +12 -29
- package/dist/utilities/form/paymentForm/BankAccountForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/BankAccountForm.js +64 -78
- package/dist/utilities/form/paymentForm/BankAccountForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/BankAccountForm.mjs +77 -196
- package/dist/utilities/form/paymentForm/BankAccountForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/CashForm.d.ts +1 -1
- package/dist/utilities/form/paymentForm/CashForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/CashForm.js +19 -51
- package/dist/utilities/form/paymentForm/CashForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/CashForm.mjs +80 -119
- package/dist/utilities/form/paymentForm/CashForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardForm.d.ts +10 -21
- package/dist/utilities/form/paymentForm/CreditCardForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardForm.js +81 -87
- package/dist/utilities/form/paymentForm/CreditCardForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardForm.mjs +84 -195
- package/dist/utilities/form/paymentForm/CreditCardForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardUtils.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardUtils.js +5 -0
- package/dist/utilities/form/paymentForm/CreditCardUtils.js.map +1 -1
- package/dist/utilities/form/paymentForm/CreditCardUtils.mjs +1 -0
- package/dist/utilities/form/paymentForm/CreditCardUtils.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/HostedPaymentError.d.ts +5 -16
- package/dist/utilities/form/paymentForm/HostedPaymentError.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/HostedPaymentError.js +6 -18
- package/dist/utilities/form/paymentForm/HostedPaymentError.js.map +1 -1
- package/dist/utilities/form/paymentForm/HostedPaymentError.mjs +18 -55
- package/dist/utilities/form/paymentForm/HostedPaymentError.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/NewCreditCardForm.d.ts +12 -14
- package/dist/utilities/form/paymentForm/NewCreditCardForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/NewCreditCardForm.js +45 -58
- package/dist/utilities/form/paymentForm/NewCreditCardForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/NewCreditCardForm.mjs +185 -262
- package/dist/utilities/form/paymentForm/NewCreditCardForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/NewECheckForm.d.ts +9 -14
- package/dist/utilities/form/paymentForm/NewECheckForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/NewECheckForm.js +28 -68
- package/dist/utilities/form/paymentForm/NewECheckForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/NewECheckForm.mjs +184 -227
- package/dist/utilities/form/paymentForm/NewECheckForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentBankDetails.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentBankDetails.js +4 -2
- package/dist/utilities/form/paymentForm/PaymentBankDetails.js.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentCardDetail.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentCardDetail.js +4 -2
- package/dist/utilities/form/paymentForm/PaymentCardDetail.js.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentForm.d.ts +67 -3
- package/dist/utilities/form/paymentForm/PaymentForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentForm.js +265 -246
- package/dist/utilities/form/paymentForm/PaymentForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/PaymentForm.mjs +275 -296
- package/dist/utilities/form/paymentForm/PaymentForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/usePaymentContext.d.ts +22 -0
- package/dist/utilities/form/paymentForm/usePaymentContext.d.ts.map +1 -0
- package/dist/utilities/form/paymentForm/usePaymentContext.js +117 -0
- package/dist/utilities/form/paymentForm/usePaymentContext.js.map +1 -0
- package/dist/utilities/form/paymentForm/usePaymentContext.mjs +119 -0
- package/dist/utilities/form/paymentForm/usePaymentContext.mjs.map +1 -0
- package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.js +22 -28
- package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.mjs +37 -32
- package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.js +25 -27
- package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.mjs +40 -38
- package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.mjs.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.d.ts.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.js +25 -32
- package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.js.map +1 -1
- package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.mjs +38 -43
- package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.mjs.map +1 -1
- package/package.json +6 -42
- package/dist/utilities/form/paymentForm/BankIcon.mjs +0 -56
- package/dist/utilities/form/paymentForm/BankIcon.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/CashIcon.mjs +0 -55
- package/dist/utilities/form/paymentForm/CashIcon.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/CheckIcon.mjs +0 -62
- package/dist/utilities/form/paymentForm/CheckIcon.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/CreditCardIcon.mjs +0 -85
- package/dist/utilities/form/paymentForm/CreditCardIcon.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/DisableOverlay.mjs +0 -44
- package/dist/utilities/form/paymentForm/DisableOverlay.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentBankDetails.mjs +0 -161
- package/dist/utilities/form/paymentForm/PaymentBankDetails.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentCard.d.ts +0 -13
- package/dist/utilities/form/paymentForm/PaymentCard.d.ts.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentCard.js +0 -54
- package/dist/utilities/form/paymentForm/PaymentCard.js.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentCard.mjs +0 -96
- package/dist/utilities/form/paymentForm/PaymentCard.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentCardDetail.mjs +0 -284
- package/dist/utilities/form/paymentForm/PaymentCardDetail.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/PaymentDropdown.mjs +0 -142
- package/dist/utilities/form/paymentForm/PaymentDropdown.mjs.map +0 -1
- package/dist/utilities/form/paymentForm/TabPanel.mjs +0 -74
- package/dist/utilities/form/paymentForm/TabPanel.mjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { PaymentDetails, PaymentMethodData } from './AccountPayment.model';
|
|
2
3
|
import { PaymentVendorFactoryEnum } from '../../../enums/paymentVendorFactoryEnum';
|
|
3
4
|
interface BankAccountFormProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
bankAccountTypes?: any[];
|
|
5
|
+
bankAccountTypes?: {
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
9
|
isFormDisabled?: boolean;
|
|
10
10
|
paymentDetails: PaymentDetails;
|
|
11
11
|
providerType?: PaymentVendorFactoryEnum | null;
|
|
@@ -16,34 +16,17 @@ interface BankAccountFormProps {
|
|
|
16
16
|
onStatusChange?: (paymentFormResult: any) => void;
|
|
17
17
|
enabled?: boolean | null;
|
|
18
18
|
actionLabel?: string;
|
|
19
|
+
/** When false, the manual eCheck form hides its "save" checkbox. */
|
|
20
|
+
allowSaveMethod?: boolean;
|
|
19
21
|
data?: PaymentMethodData;
|
|
20
22
|
externalId?: string;
|
|
23
|
+
setSelectedPaymentAccount?: (paymentAccount: any) => void;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} props - The properties passed to the component.
|
|
27
|
-
* @param {Array} props.bankAccountTypes - An array of available bank account types.
|
|
28
|
-
* @param {Object} props.data - Data related to the bank account form.
|
|
29
|
-
* @param {string} props.externalId - External identifier for the bank account.
|
|
30
|
-
* @param {boolean} [props.isFormDisabled=false] - Flag to disable the form.
|
|
31
|
-
* @param {string|null} [props.providerType=null] - Type of the payment provider.
|
|
32
|
-
* @param {Object|null} [props.providerProps=null] - Properties for the payment provider.
|
|
33
|
-
* @param {Object} props.paymentDetails - Details of the payment.
|
|
34
|
-
* @param {boolean} props.isHostedPaymentPage - Flag to indicate if it is a hosted payment page.
|
|
35
|
-
* @param {boolean} props.hasReadPropertiesError - Flag to indicate if there was an error reading properties.
|
|
36
|
-
* @param {string} props.readPropertiesMessageError - Error message for reading properties.
|
|
37
|
-
* @param {Function} props.onStatusChange - Callback function to handle status changes.
|
|
38
|
-
* @param {boolean} props.enabled - Flag to indicate if the form is enabled.
|
|
39
|
-
* @param {Function} props.setSelectedPaymentAccount - Callback function to set the selected payment account.
|
|
40
|
-
* @param {string} props.actionLabel - The label for the action button.
|
|
41
|
-
* @param {Object} restProps - Additional properties passed to the component.
|
|
42
|
-
*
|
|
43
|
-
* @returns {JSX.Element} The rendered component.
|
|
26
|
+
* eCheck / bank-account branch of the payment form. Mirrors the credit-card
|
|
27
|
+
* branch: radio list of saved accounts when any exist + "Other / new account"
|
|
28
|
+
* option per D3, otherwise renders the appropriate entry form directly.
|
|
44
29
|
*/
|
|
45
|
-
export declare const BankAccountForm: ({ bankAccountTypes, data, externalId, isFormDisabled, providerType, providerProps, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange,
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
}) => any;
|
|
30
|
+
export declare const BankAccountForm: ({ bankAccountTypes, data, externalId, isFormDisabled, providerType, providerProps, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange, actionLabel, allowSaveMethod, setSelectedPaymentAccount, }: BankAccountFormProps) => React.JSX.Element;
|
|
48
31
|
export {};
|
|
49
32
|
//# sourceMappingURL=BankAccountForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankAccountForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BankAccountForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAQnF,UAAU,oBAAoB;IAC5B,gBAAgB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yBAAyB,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,CAAC;CAC3D;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,qSAgI3B,CAAC"}
|
|
@@ -1,94 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useEffect, useState } from 'react';
|
|
13
|
-
import { makeStyles } from '@material-ui/core';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
14
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { UdpFlexbox } from '../../../UI/fluent-web-components/UdpFlexbox';
|
|
4
|
+
import { UdpRadioGroup } from '../../../UI/fluent-web-components/UdpRadioGroup';
|
|
5
|
+
import { UdpSpinner } from '../../../UI/fluent-web-components/UdpSpinner';
|
|
15
6
|
import { usePaymentProviderForm } from './usePaymentProviderForm';
|
|
16
7
|
import { PaymentTenderTypeEnum } from '../../../enums/paymentTenderTypeEnum';
|
|
17
|
-
import {
|
|
18
|
-
import { useAxiosGet } from '../../useAxiosGet';
|
|
19
|
-
import { Box } from '../../../UI/Box';
|
|
20
|
-
import { LinearProgress } from '../../../UI/loading/LinearProgress';
|
|
21
|
-
import PaymentDropdown from './PaymentDropdown';
|
|
22
|
-
import { FluentButton } from '../../../UI/inputs/buttons/FluentButton';
|
|
23
|
-
import { UnityFluentIcon } from '../../iconLibrary/UnityFluentIcon';
|
|
24
|
-
import { getIconFromName } from '../../tree/TreeUtilities';
|
|
8
|
+
import { useApiQuery } from '../../useApiQuery';
|
|
25
9
|
import { HostedPaymentError } from './HostedPaymentError';
|
|
26
10
|
import { NewECheckForm } from './NewECheckForm';
|
|
27
11
|
import { ConfigService } from '../../../configService';
|
|
28
|
-
const
|
|
29
|
-
formControl: {
|
|
30
|
-
width: '100%',
|
|
31
|
-
marginTop: '5px'
|
|
32
|
-
},
|
|
33
|
-
formControlCheck: {
|
|
34
|
-
width: '100%',
|
|
35
|
-
marginTop: '5px',
|
|
36
|
-
marginLeft: '3px'
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
12
|
+
const OTHER_RADIO_VALUE = '__other__';
|
|
39
13
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} props - The properties passed to the component.
|
|
44
|
-
* @param {Array} props.bankAccountTypes - An array of available bank account types.
|
|
45
|
-
* @param {Object} props.data - Data related to the bank account form.
|
|
46
|
-
* @param {string} props.externalId - External identifier for the bank account.
|
|
47
|
-
* @param {boolean} [props.isFormDisabled=false] - Flag to disable the form.
|
|
48
|
-
* @param {string|null} [props.providerType=null] - Type of the payment provider.
|
|
49
|
-
* @param {Object|null} [props.providerProps=null] - Properties for the payment provider.
|
|
50
|
-
* @param {Object} props.paymentDetails - Details of the payment.
|
|
51
|
-
* @param {boolean} props.isHostedPaymentPage - Flag to indicate if it is a hosted payment page.
|
|
52
|
-
* @param {boolean} props.hasReadPropertiesError - Flag to indicate if there was an error reading properties.
|
|
53
|
-
* @param {string} props.readPropertiesMessageError - Error message for reading properties.
|
|
54
|
-
* @param {Function} props.onStatusChange - Callback function to handle status changes.
|
|
55
|
-
* @param {boolean} props.enabled - Flag to indicate if the form is enabled.
|
|
56
|
-
* @param {Function} props.setSelectedPaymentAccount - Callback function to set the selected payment account.
|
|
57
|
-
* @param {string} props.actionLabel - The label for the action button.
|
|
58
|
-
* @param {Object} restProps - Additional properties passed to the component.
|
|
59
|
-
*
|
|
60
|
-
* @returns {JSX.Element} The rendered component.
|
|
14
|
+
* eCheck / bank-account branch of the payment form. Mirrors the credit-card
|
|
15
|
+
* branch: radio list of saved accounts when any exist + "Other / new account"
|
|
16
|
+
* option per D3, otherwise renders the appropriate entry form directly.
|
|
61
17
|
*/
|
|
62
|
-
export const BankAccountForm = (
|
|
63
|
-
var { bankAccountTypes = [], data, externalId, isFormDisabled = false, providerType = null, providerProps = null, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange, enabled, actionLabel, setSelectedPaymentAccount } = _a, restProps = __rest(_a, ["bankAccountTypes", "data", "externalId", "isFormDisabled", "providerType", "providerProps", "paymentDetails", "isHostedPaymentPage", "hasReadPropertiesError", "readPropertiesMessageError", "onStatusChange", "enabled", "actionLabel", "setSelectedPaymentAccount"]);
|
|
64
|
-
const classes = useStyles();
|
|
18
|
+
export const BankAccountForm = ({ bankAccountTypes = [], data, externalId, isFormDisabled = false, providerType = null, providerProps = null, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange, actionLabel, allowSaveMethod = true, setSelectedPaymentAccount, }) => {
|
|
65
19
|
const { t } = useTranslation();
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const [{ data: paymentAccounts, loading: loadingPaymentAccounts }] = useAxiosGet(ConfigService.pgV1ApiUrl, `PaymentTokenECheck/${externalId}`, {}, false);
|
|
71
|
-
const handleShowHostedPaymentPage = () => {
|
|
72
|
-
setShowHostedPaymentPage(true);
|
|
73
|
-
onStatusChange && onStatusChange({ isValid: false });
|
|
74
|
-
};
|
|
20
|
+
const { data: paymentAccounts, isLoading: loadingPaymentAccounts } = useApiQuery(ConfigService.pgV1ApiUrl, `PaymentTokenECheck/${externalId}`, {}, { enabled: Boolean(externalId) });
|
|
21
|
+
const savedMethods = paymentAccounts !== null && paymentAccounts !== void 0 ? paymentAccounts : [];
|
|
22
|
+
const hasSavedMethods = savedMethods.length > 0;
|
|
23
|
+
const [selected, setSelected] = useState(OTHER_RADIO_VALUE);
|
|
75
24
|
useEffect(() => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
25
|
+
var _a;
|
|
26
|
+
setSelected(((_a = savedMethods[0]) === null || _a === void 0 ? void 0 : _a.paymentTokenID) || OTHER_RADIO_VALUE);
|
|
27
|
+
}, [savedMethods]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (selected && selected !== OTHER_RADIO_VALUE) {
|
|
30
|
+
const sel = savedMethods.find((s) => (s === null || s === void 0 ? void 0 : s.paymentTokenID) === selected);
|
|
31
|
+
setSelectedPaymentAccount === null || setSelectedPaymentAccount === void 0 ? void 0 : setSelectedPaymentAccount(sel || null);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setSelectedPaymentAccount === null || setSelectedPaymentAccount === void 0 ? void 0 : setSelectedPaymentAccount(null);
|
|
35
|
+
}
|
|
36
|
+
}, [selected, savedMethods, setSelectedPaymentAccount]);
|
|
37
|
+
const showOtherForm = selected === OTHER_RADIO_VALUE;
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!showOtherForm) {
|
|
40
|
+
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: true });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (isHostedPaymentPage === false) {
|
|
44
|
+
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: true });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: false });
|
|
48
|
+
}
|
|
49
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
+
}, [showOtherForm, isHostedPaymentPage]);
|
|
51
|
+
const paymentProviderForm = usePaymentProviderForm(PaymentTenderTypeEnum.ECheck, providerType, providerProps, onStatusChange, paymentDetails, data);
|
|
52
|
+
const items = useMemo(() => {
|
|
53
|
+
const savedItems = savedMethods.map((m) => {
|
|
54
|
+
var _a;
|
|
55
|
+
var _b, _c;
|
|
56
|
+
const nickname = (_b = (_a = m === null || m === void 0 ? void 0 : m.paymentToken) === null || _a === void 0 ? void 0 : _a.nickname) !== null && _b !== void 0 ? _b : t('Saved account');
|
|
57
|
+
const routing = (m === null || m === void 0 ? void 0 : m.routingNumber) ? ` (${m.routingNumber})` : '';
|
|
58
|
+
return {
|
|
59
|
+
label: `${nickname}${routing}`,
|
|
60
|
+
value: String((_c = m === null || m === void 0 ? void 0 : m.paymentTokenID) !== null && _c !== void 0 ? _c : ''),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return [
|
|
64
|
+
...savedItems,
|
|
65
|
+
{
|
|
66
|
+
label: actionLabel || t('Use a different account'),
|
|
67
|
+
value: OTHER_RADIO_VALUE,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}, [savedMethods, actionLabel, t]);
|
|
81
71
|
if (loadingPaymentAccounts) {
|
|
82
|
-
return (React.createElement(
|
|
83
|
-
}
|
|
84
|
-
if (!showHostedPaymentPage && (paymentAccounts === null || paymentAccounts === void 0 ? void 0 : paymentAccounts.length) > 0) {
|
|
85
|
-
return (React.createElement(React.Fragment, null, React.createElement(PaymentDropdown, { paymentAccounts: paymentAccounts, setSelectedPaymentAccount: setSelectedPaymentAccount, paymentType: PaymentTenderTypeEnum.ECheck }), React.createElement(Box, { textAlign: "center", mt: 3 }, React.createElement(FluentButton, { variant: "outlined", color: "primary", onClick: handleShowHostedPaymentPage, size: "small", startIcon: React.createElement(UnityFluentIcon, { icon: getIconFromName('BankIcon') }), style: { padding: "18px 20px" } }, actionLabel || t('Enter Bank Account Details')))));
|
|
72
|
+
return (React.createElement(UdpFlexbox, { direction: "row", justify: "center", align: "center" }, React.createElement(UdpSpinner, { size: "medium" })));
|
|
86
73
|
}
|
|
87
74
|
if (hasReadPropertiesError) {
|
|
88
|
-
return (React.createElement(HostedPaymentError, { error:
|
|
75
|
+
return (React.createElement(HostedPaymentError, { error: t('Configuration error'), message: readPropertiesMessageError || t('Unknown error') }));
|
|
89
76
|
}
|
|
90
|
-
return
|
|
91
|
-
isHostedPaymentPage ?
|
|
92
|
-
paymentProviderForm : (React.createElement(NewECheckForm, { isFormDisabled: isFormDisabled, classes: classes, bankAccountTypes: bankAccountTypes }));
|
|
77
|
+
return (React.createElement(UdpFlexbox, { direction: "column", gap: "sm", wrap: "nowrap" }, hasSavedMethods && (React.createElement(UdpRadioGroup, { label: t('Saved accounts'), name: "savedBankAccount", orientation: "vertical", disabled: isFormDisabled, value: selected, items: items, onChange: (e) => setSelected(String(e.target.value)) })), showOtherForm &&
|
|
78
|
+
(isHostedPaymentPage ? (paymentProviderForm) : (React.createElement(NewECheckForm, { isFormDisabled: isFormDisabled, bankAccountTypes: bankAccountTypes, allowSaveMethod: allowSaveMethod })))));
|
|
93
79
|
};
|
|
94
80
|
//# sourceMappingURL=BankAccountForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankAccountForm.js","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BankAccountForm.js","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"names":[],"mappings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AAC,UAAU,IAAC,SAAS,EAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAC,KAAK,EAAC,QAAQ,IACzD,oBAAC,UAAU,IAAC,IAAI,EAAC,QAAQ,GAAG,CACjB,CACd,CAAC;IACJ,CAAC;IAED,IAAI,sBAAsB,EAAE,CAAC;QAC3B,OAAO,CACL,oBAAC,kBAAkB,IACjB,KAAK,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAC/B,OAAO,EAAE,0BAA0B,IAAI,CAAC,CAAC,eAAe,CAAC,GACzD,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,UAAU,IAAC,SAAS,EAAC,QAAQ,EAAC,GAAG,EAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,IAClD,eAAe,IAAI,CAClB,oBAAC,aAAa,IACZ,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAC1B,IAAI,EAAC,kBAAkB,EACvB,WAAW,EAAC,UAAU,EACtB,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACpD,CACH,EAEA,aAAa;QACZ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CACrB,mBAAmB,CACpB,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,GAChC,CACH,CAAC,CACO,CACd,CAAC;AAAA,CACH,CAAC"}
|
|
@@ -1,210 +1,91 @@
|
|
|
1
|
-
import { c } from "../../../reactCompilerRuntime.mjs";
|
|
2
|
-
import { FluentButton } from "../../../UI/inputs/buttons/FluentButton.mjs";
|
|
3
1
|
import { ConfigService } from "../../../configService/index.mjs";
|
|
4
|
-
import { useUser } from "../../auth/useUser.mjs";
|
|
5
|
-
import { UnityFluentIcon } from "../../iconLibrary/UnityFluentIcon.mjs";
|
|
6
|
-
import { getIconFromName } from "../../tree/TreeUtilities.mjs";
|
|
7
|
-
import { useAxiosGet } from "../../useAxiosGet.mjs";
|
|
8
2
|
import { PaymentTenderTypeEnum } from "../../../enums/paymentTenderTypeEnum.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { useApiQuery } from "../../useApiQuery.mjs";
|
|
4
|
+
import { UdpFlexbox } from "../../../UI/fluent-web-components/UdpFlexbox.mjs";
|
|
5
|
+
import { UdpRadioGroup } from "../../../UI/fluent-web-components/UdpRadioGroup.mjs";
|
|
6
|
+
import { UdpSpinner } from "../../../UI/fluent-web-components/UdpSpinner.mjs";
|
|
11
7
|
import { usePaymentProviderForm } from "./usePaymentProviderForm.mjs";
|
|
12
|
-
import PaymentDropdown from "./PaymentDropdown.mjs";
|
|
13
8
|
import { HostedPaymentError } from "./HostedPaymentError.mjs";
|
|
14
9
|
import { NewECheckForm } from "./NewECheckForm.mjs";
|
|
15
|
-
import React, { useEffect, useState } from "react";
|
|
16
|
-
import { makeStyles } from "@material-ui/core";
|
|
10
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
17
11
|
import { useTranslation } from "react-i18next";
|
|
18
12
|
//#region src/utilities/form/paymentForm/BankAccountForm.tsx
|
|
19
|
-
const
|
|
20
|
-
formControl: {
|
|
21
|
-
width: "100%",
|
|
22
|
-
marginTop: "5px"
|
|
23
|
-
},
|
|
24
|
-
formControlCheck: {
|
|
25
|
-
width: "100%",
|
|
26
|
-
marginTop: "5px",
|
|
27
|
-
marginLeft: "3px"
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
13
|
+
const OTHER_RADIO_VALUE = "__other__";
|
|
30
14
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} props - The properties passed to the component.
|
|
35
|
-
* @param {Array} props.bankAccountTypes - An array of available bank account types.
|
|
36
|
-
* @param {Object} props.data - Data related to the bank account form.
|
|
37
|
-
* @param {string} props.externalId - External identifier for the bank account.
|
|
38
|
-
* @param {boolean} [props.isFormDisabled=false] - Flag to disable the form.
|
|
39
|
-
* @param {string|null} [props.providerType=null] - Type of the payment provider.
|
|
40
|
-
* @param {Object|null} [props.providerProps=null] - Properties for the payment provider.
|
|
41
|
-
* @param {Object} props.paymentDetails - Details of the payment.
|
|
42
|
-
* @param {boolean} props.isHostedPaymentPage - Flag to indicate if it is a hosted payment page.
|
|
43
|
-
* @param {boolean} props.hasReadPropertiesError - Flag to indicate if there was an error reading properties.
|
|
44
|
-
* @param {string} props.readPropertiesMessageError - Error message for reading properties.
|
|
45
|
-
* @param {Function} props.onStatusChange - Callback function to handle status changes.
|
|
46
|
-
* @param {boolean} props.enabled - Flag to indicate if the form is enabled.
|
|
47
|
-
* @param {Function} props.setSelectedPaymentAccount - Callback function to set the selected payment account.
|
|
48
|
-
* @param {string} props.actionLabel - The label for the action button.
|
|
49
|
-
* @param {Object} restProps - Additional properties passed to the component.
|
|
50
|
-
*
|
|
51
|
-
* @returns {JSX.Element} The rendered component.
|
|
15
|
+
* eCheck / bank-account branch of the payment form. Mirrors the credit-card
|
|
16
|
+
* branch: radio list of saved accounts when any exist + "Other / new account"
|
|
17
|
+
* option per D3, otherwise renders the appropriate entry form directly.
|
|
52
18
|
*/
|
|
53
|
-
const BankAccountForm = (
|
|
54
|
-
const $ = c(39);
|
|
55
|
-
const { bankAccountTypes: t1, data, externalId, isFormDisabled: t2, providerType: t3, providerProps: t4, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange, actionLabel, setSelectedPaymentAccount } = t0;
|
|
56
|
-
let t5;
|
|
57
|
-
if ($[0] !== t1) {
|
|
58
|
-
t5 = t1 === void 0 ? [] : t1;
|
|
59
|
-
$[0] = t1;
|
|
60
|
-
$[1] = t5;
|
|
61
|
-
} else t5 = $[1];
|
|
62
|
-
const bankAccountTypes = t5;
|
|
63
|
-
const isFormDisabled = t2 === void 0 ? false : t2;
|
|
64
|
-
const providerType = t3 === void 0 ? null : t3;
|
|
65
|
-
const providerProps = t4 === void 0 ? null : t4;
|
|
66
|
-
const classes = useStyles();
|
|
19
|
+
const BankAccountForm = ({ bankAccountTypes = [], data, externalId, isFormDisabled = false, providerType = null, providerProps = null, paymentDetails, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, onStatusChange, actionLabel, allowSaveMethod = true, setSelectedPaymentAccount }) => {
|
|
67
20
|
const { t } = useTranslation();
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
t9 = () => {
|
|
91
|
-
const showHostedPaymentPageByDefault = isHostedPaymentPage && paymentAccounts?.length > 0;
|
|
92
|
-
const enableSubmitForm = isHostedPaymentPage === false || paymentAccounts?.length > 0;
|
|
93
|
-
setShowHostedPaymentPage(!showHostedPaymentPageByDefault);
|
|
94
|
-
onStatusChange && onStatusChange({ isValid: enableSubmitForm });
|
|
95
|
-
};
|
|
96
|
-
$[5] = isHostedPaymentPage;
|
|
97
|
-
$[6] = onStatusChange;
|
|
98
|
-
$[7] = paymentAccounts?.length;
|
|
99
|
-
$[8] = t9;
|
|
100
|
-
} else t9 = $[8];
|
|
101
|
-
let t10;
|
|
102
|
-
if ($[9] !== isHostedPaymentPage || $[10] !== paymentAccounts) {
|
|
103
|
-
t10 = [isHostedPaymentPage, paymentAccounts];
|
|
104
|
-
$[9] = isHostedPaymentPage;
|
|
105
|
-
$[10] = paymentAccounts;
|
|
106
|
-
$[11] = t10;
|
|
107
|
-
} else t10 = $[11];
|
|
108
|
-
useEffect(t9, t10);
|
|
109
|
-
if (loadingPaymentAccounts) {
|
|
110
|
-
let t11;
|
|
111
|
-
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
-
t11 = /* @__PURE__ */ React.createElement(Box$1, { sx: { width: "100%" } }, /* @__PURE__ */ React.createElement(LinearProgress$1, null));
|
|
113
|
-
$[12] = t11;
|
|
114
|
-
} else t11 = $[12];
|
|
115
|
-
return t11;
|
|
116
|
-
}
|
|
117
|
-
if (!showHostedPaymentPage && paymentAccounts?.length > 0) {
|
|
118
|
-
let t11;
|
|
119
|
-
if ($[13] !== paymentAccounts || $[14] !== setSelectedPaymentAccount) {
|
|
120
|
-
t11 = /* @__PURE__ */ React.createElement(PaymentDropdown, {
|
|
121
|
-
paymentAccounts,
|
|
122
|
-
setSelectedPaymentAccount,
|
|
123
|
-
paymentType: PaymentTenderTypeEnum.ECheck
|
|
124
|
-
});
|
|
125
|
-
$[13] = paymentAccounts;
|
|
126
|
-
$[14] = setSelectedPaymentAccount;
|
|
127
|
-
$[15] = t11;
|
|
128
|
-
} else t11 = $[15];
|
|
129
|
-
let t12;
|
|
130
|
-
let t13;
|
|
131
|
-
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
132
|
-
t12 = /* @__PURE__ */ React.createElement(UnityFluentIcon, { icon: getIconFromName("BankIcon") });
|
|
133
|
-
t13 = { padding: "18px 20px" };
|
|
134
|
-
$[16] = t12;
|
|
135
|
-
$[17] = t13;
|
|
136
|
-
} else {
|
|
137
|
-
t12 = $[16];
|
|
138
|
-
t13 = $[17];
|
|
21
|
+
const { data: paymentAccounts, isLoading: loadingPaymentAccounts } = useApiQuery(ConfigService.pgV1ApiUrl, `PaymentTokenECheck/${externalId}`, {}, { enabled: Boolean(externalId) });
|
|
22
|
+
const savedMethods = paymentAccounts ?? [];
|
|
23
|
+
const hasSavedMethods = savedMethods.length > 0;
|
|
24
|
+
const [selected, setSelected] = useState(OTHER_RADIO_VALUE);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setSelected(savedMethods[0]?.paymentTokenID || OTHER_RADIO_VALUE);
|
|
27
|
+
}, [savedMethods]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (selected && selected !== OTHER_RADIO_VALUE) {
|
|
30
|
+
const sel = savedMethods.find((s) => s?.paymentTokenID === selected);
|
|
31
|
+
setSelectedPaymentAccount?.(sel || null);
|
|
32
|
+
} else setSelectedPaymentAccount?.(null);
|
|
33
|
+
}, [
|
|
34
|
+
selected,
|
|
35
|
+
savedMethods,
|
|
36
|
+
setSelectedPaymentAccount
|
|
37
|
+
]);
|
|
38
|
+
const showOtherForm = selected === OTHER_RADIO_VALUE;
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!showOtherForm) {
|
|
41
|
+
onStatusChange?.({ isValid: true });
|
|
42
|
+
return;
|
|
139
43
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
message: t11
|
|
186
|
-
});
|
|
187
|
-
$[30] = t11;
|
|
188
|
-
$[31] = t12;
|
|
189
|
-
} else t12 = $[31];
|
|
190
|
-
return t12;
|
|
191
|
-
}
|
|
192
|
-
let t11;
|
|
193
|
-
if ($[32] !== bankAccountTypes || $[33] !== classes || $[34] !== isFormDisabled || $[35] !== isHostedPaymentPage || $[36] !== paymentProviderForm || $[37] !== showHostedPaymentPage) {
|
|
194
|
-
t11 = showHostedPaymentPage && isHostedPaymentPage ? paymentProviderForm : /* @__PURE__ */ React.createElement(NewECheckForm, {
|
|
195
|
-
isFormDisabled,
|
|
196
|
-
classes,
|
|
197
|
-
bankAccountTypes
|
|
198
|
-
});
|
|
199
|
-
$[32] = bankAccountTypes;
|
|
200
|
-
$[33] = classes;
|
|
201
|
-
$[34] = isFormDisabled;
|
|
202
|
-
$[35] = isHostedPaymentPage;
|
|
203
|
-
$[36] = paymentProviderForm;
|
|
204
|
-
$[37] = showHostedPaymentPage;
|
|
205
|
-
$[38] = t11;
|
|
206
|
-
} else t11 = $[38];
|
|
207
|
-
return t11;
|
|
44
|
+
if (isHostedPaymentPage === false) onStatusChange?.({ isValid: true });
|
|
45
|
+
else onStatusChange?.({ isValid: false });
|
|
46
|
+
}, [showOtherForm, isHostedPaymentPage]);
|
|
47
|
+
const paymentProviderForm = usePaymentProviderForm(PaymentTenderTypeEnum.ECheck, providerType, providerProps, onStatusChange, paymentDetails, data);
|
|
48
|
+
const items = useMemo(() => {
|
|
49
|
+
return [...savedMethods.map((m) => {
|
|
50
|
+
return {
|
|
51
|
+
label: `${m?.paymentToken?.nickname ?? t("Saved account")}${m?.routingNumber ? ` (${m.routingNumber})` : ""}`,
|
|
52
|
+
value: String(m?.paymentTokenID ?? "")
|
|
53
|
+
};
|
|
54
|
+
}), {
|
|
55
|
+
label: actionLabel || t("Use a different account"),
|
|
56
|
+
value: OTHER_RADIO_VALUE
|
|
57
|
+
}];
|
|
58
|
+
}, [
|
|
59
|
+
savedMethods,
|
|
60
|
+
actionLabel,
|
|
61
|
+
t
|
|
62
|
+
]);
|
|
63
|
+
if (loadingPaymentAccounts) return /* @__PURE__ */ React.createElement(UdpFlexbox, {
|
|
64
|
+
direction: "row",
|
|
65
|
+
justify: "center",
|
|
66
|
+
align: "center"
|
|
67
|
+
}, /* @__PURE__ */ React.createElement(UdpSpinner, { size: "medium" }));
|
|
68
|
+
if (hasReadPropertiesError) return /* @__PURE__ */ React.createElement(HostedPaymentError, {
|
|
69
|
+
error: t("Configuration error"),
|
|
70
|
+
message: readPropertiesMessageError || t("Unknown error")
|
|
71
|
+
});
|
|
72
|
+
return /* @__PURE__ */ React.createElement(UdpFlexbox, {
|
|
73
|
+
direction: "column",
|
|
74
|
+
gap: "sm",
|
|
75
|
+
wrap: "nowrap"
|
|
76
|
+
}, hasSavedMethods && /* @__PURE__ */ React.createElement(UdpRadioGroup, {
|
|
77
|
+
label: t("Saved accounts"),
|
|
78
|
+
name: "savedBankAccount",
|
|
79
|
+
orientation: "vertical",
|
|
80
|
+
disabled: isFormDisabled,
|
|
81
|
+
value: selected,
|
|
82
|
+
items,
|
|
83
|
+
onChange: (e) => setSelected(String(e.target.value))
|
|
84
|
+
}), showOtherForm && (isHostedPaymentPage ? paymentProviderForm : /* @__PURE__ */ React.createElement(NewECheckForm, {
|
|
85
|
+
isFormDisabled,
|
|
86
|
+
bankAccountTypes,
|
|
87
|
+
allowSaveMethod
|
|
88
|
+
})));
|
|
208
89
|
};
|
|
209
90
|
//#endregion
|
|
210
91
|
export { BankAccountForm };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankAccountForm.mjs","names":["React","useEffect","useState","makeStyles","useTranslation","usePaymentProviderForm","PaymentDetails","PaymentMethodData","PaymentTenderTypeEnum","PaymentVendorFactoryEnum","useUser","useAxiosGet","Box","LinearProgress","PaymentDropdown","FluentButton","UnityFluentIcon","getIconFromName","HostedPaymentError","NewECheckForm","ConfigService","BankAccountFormProps","accountTypes","isFormDisabled","useStyles","theme","formControl","width","marginTop","formControlCheck","marginLeft","bankAccountTypes","paymentDetails","providerType","providerProps","isHostedPaymentPage","hasReadPropertiesError","readPropertiesMessageError","onStatusChange","paymentFormResult","enabled","actionLabel","data","externalId","BankAccountForm","t0","$","_c","t1","t2","t3","t4","setSelectedPaymentAccount","t5","undefined","classes","t","paymentProviderForm","ECheck","showHostedPaymentPage","setShowHostedPaymentPage","t6","Symbol","for","t7","pgV1ApiUrl","paymentAccounts","loading","loadingPaymentAccounts","t8","isValid","handleShowHostedPaymentPage","t9","length","showHostedPaymentPageByDefault","enableSubmitForm","t10","t11","t12","t13","padding","t14","t15","t16"],"sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport {\n makeStyles} from '@material-ui/core';\nimport { useTranslation } from 'react-i18next';\nimport { usePaymentProviderForm } from './usePaymentProviderForm';\nimport { PaymentDetails, PaymentMethodData } from './AccountPayment.model';\nimport { PaymentTenderTypeEnum } from '../../../enums/paymentTenderTypeEnum';\nimport { PaymentVendorFactoryEnum } from '../../../enums/paymentVendorFactoryEnum';\nimport { useUser } from '../../auth/useUser';\nimport { useAxiosGet } from '../../useAxiosGet';\nimport { Box } from '../../../UI/Box';\nimport { LinearProgress } from '../../../UI/loading/LinearProgress';\nimport PaymentDropdown from './PaymentDropdown';\nimport { FluentButton } from '../../../UI/inputs/buttons/FluentButton';\nimport { UnityFluentIcon } from '../../iconLibrary/UnityFluentIcon';\nimport { getIconFromName } from '../../tree/TreeUtilities';\nimport { HostedPaymentError } from './HostedPaymentError';\nimport { NewECheckForm } from './NewECheckForm';\nimport { ConfigService } from '../../../configService';\n\ninterface BankAccountFormProps {\n accountTypes?: any[];\n isFormDisabled?: boolean;\n}\n\nconst useStyles = makeStyles((theme) => ({\n formControl: {\n width: '100%',\n marginTop: '5px'\n },\n formControlCheck: {\n width: '100%',\n marginTop: '5px',\n marginLeft: '3px'\n }\n}));\n\ninterface BankAccountFormProps {\n bankAccountTypes?: any[];\n isFormDisabled?: boolean;\n paymentDetails: PaymentDetails;\n providerType?: PaymentVendorFactoryEnum | null;\n providerProps?: any;\n isHostedPaymentPage?: boolean | null;\n hasReadPropertiesError?: boolean | null;\n readPropertiesMessageError?: string | null;\n onStatusChange?: (paymentFormResult: any) => void;\n enabled?: boolean | null;\n actionLabel?: string;\n data?: PaymentMethodData;\n externalId?: string;\n}\n\n/**\n * `BankAccountForm` is a React functional component that renders a form for managing bank accounts.\n * It supports both hosted payment pages and direct input forms for bank account details.\n *\n * @param {Object} props - The properties passed to the component.\n * @param {Array} props.bankAccountTypes - An array of available bank account types.\n * @param {Object} props.data - Data related to the bank account form.\n * @param {string} props.externalId - External identifier for the bank account.\n * @param {boolean} [props.isFormDisabled=false] - Flag to disable the form.\n * @param {string|null} [props.providerType=null] - Type of the payment provider.\n * @param {Object|null} [props.providerProps=null] - Properties for the payment provider.\n * @param {Object} props.paymentDetails - Details of the payment.\n * @param {boolean} props.isHostedPaymentPage - Flag to indicate if it is a hosted payment page.\n * @param {boolean} props.hasReadPropertiesError - Flag to indicate if there was an error reading properties.\n * @param {string} props.readPropertiesMessageError - Error message for reading properties.\n * @param {Function} props.onStatusChange - Callback function to handle status changes.\n * @param {boolean} props.enabled - Flag to indicate if the form is enabled.\n * @param {Function} props.setSelectedPaymentAccount - Callback function to set the selected payment account.\n * @param {string} props.actionLabel - The label for the action button.\n * @param {Object} restProps - Additional properties passed to the component.\n *\n * @returns {JSX.Element} The rendered component.\n */\nexport const BankAccountForm = ({\n bankAccountTypes = [],\n data,\n externalId,\n isFormDisabled = false,\n providerType = null,\n providerProps = null,\n paymentDetails,\n isHostedPaymentPage,\n hasReadPropertiesError,\n readPropertiesMessageError,\n onStatusChange,\n enabled,\n actionLabel,\n setSelectedPaymentAccount,\n ...restProps\n}: BankAccountFormProps & { [key: string]: any }): any => {\n const classes = useStyles();\n const { t } = useTranslation();\n const user = useUser();\n\n const paymentProviderForm = usePaymentProviderForm(\n PaymentTenderTypeEnum.ECheck,\n providerType,\n providerProps,\n onStatusChange,\n paymentDetails,\n data\n );\n\n const [showHostedPaymentPage, setShowHostedPaymentPage] = useState(false);\n // @ts-ignore\n const [{ data: paymentAccounts, loading: loadingPaymentAccounts }] = useAxiosGet(\n ConfigService.pgV1ApiUrl,\n `PaymentTokenECheck/${externalId}`,\n {},\n false\n );\n\n const handleShowHostedPaymentPage = () => {\n setShowHostedPaymentPage(true);\n onStatusChange && onStatusChange({ isValid: false });\n };\n\n useEffect(() => {\n const showHostedPaymentPageByDefault = (isHostedPaymentPage && paymentAccounts?.length > 0);\n const enableSubmitForm = (isHostedPaymentPage === false || paymentAccounts?.length > 0);\n\n setShowHostedPaymentPage(!showHostedPaymentPageByDefault);\n onStatusChange && onStatusChange({ isValid: enableSubmitForm });\n }, [isHostedPaymentPage, paymentAccounts]);\n\n if (loadingPaymentAccounts) {\n return (\n <Box sx={{ width: '100%' }}>\n <LinearProgress />\n </Box>\n );\n }\n\n if (!showHostedPaymentPage && paymentAccounts?.length > 0) {\n return (\n <>\n <PaymentDropdown\n paymentAccounts={paymentAccounts}\n setSelectedPaymentAccount={setSelectedPaymentAccount}\n paymentType={PaymentTenderTypeEnum.ECheck}\n />\n <Box textAlign=\"center\" mt={3}>\n <FluentButton\n variant=\"outlined\"\n color=\"primary\"\n onClick={handleShowHostedPaymentPage}\n size=\"small\"\n startIcon={\n <UnityFluentIcon icon={getIconFromName('BankIcon')} />\n }\n style={{ padding: \"18px 20px\" }}\n >\n {actionLabel || t('Enter Bank Account Details')}\n </FluentButton>\n </Box>\n </>\n );\n }\n\n if (hasReadPropertiesError) {\n return (\n <HostedPaymentError error=\"Error\" message={readPropertiesMessageError || t('Unknown error')} />\n );\n }\n\n return showHostedPaymentPage &&\n isHostedPaymentPage ?\n paymentProviderForm : (\n <NewECheckForm\n isFormDisabled={isFormDisabled}\n classes={classes}\n bankAccountTypes={bankAccountTypes}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,MAAMwB,YAAYrB,YAAYsB,WAAW;CACvCC,aAAa;EACXC,OAAO;EACPC,WAAW;EACZ;CACDC,kBAAkB;EAChBF,OAAO;EACPC,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;AAEqBqB,SAAAxC,8BAA8BmB,EAAE,gBAAgB;AAAAV,KAAA,MAAAT;AAAAS,KAAA,MAAAU;AAAAV,KAAA,MAAA+B;QAAAA,OAAA/B,EAAA;EAAA,IAAAgC;AAAA,MAAAhC,EAAA,QAAA+B,KAAA;AAA3FC,SAAA,sBAAA,cAAC,oBAAD;IAA0B,OAAA;IAAiB,SAAAD;IAAoD,CAAA;AAAA/B,KAAA,MAAA+B;AAAA/B,KAAA,MAAAgC;QAAAA,OAAAhC,EAAA;AAAA,SAA/FgC;;CAEH,IAAAD;AAAA,KAAA/B,EAAA,QAAAf,oBAAAe,EAAA,QAAAS,WAAAT,EAAA,QAAAvB,kBAAAuB,EAAA,QAAAX,uBAAAW,EAAA,QAAAW,uBAAAX,EAAA,QAAAa,uBAAA;AAEMkB,QAAAlB,yBAAAxB,sBAAAsB,sBAGH,sBAAA,cAAC,eAAD;GACkBlC;GACPgC;GACSxB;GAErB,CAAA;AAAAe,IAAA,MAAAf;AAAAe,IAAA,MAAAS;AAAAT,IAAA,MAAAvB;AAAAuB,IAAA,MAAAX;AAAAW,IAAA,MAAAW;AAAAX,IAAA,MAAAa;AAAAb,IAAA,MAAA+B;OAAAA,OAAA/B,EAAA;AAAA,QARI+B"}
|
|
1
|
+
{"version":3,"file":"BankAccountForm.mjs","names":["React","useEffect","useMemo","useState","useTranslation","UdpFlexbox","UdpRadioGroup","UdpSpinner","usePaymentProviderForm","PaymentDetails","PaymentMethodData","PaymentTenderTypeEnum","PaymentVendorFactoryEnum","useApiQuery","HostedPaymentError","NewECheckForm","ConfigService","OTHER_RADIO_VALUE","BankAccountFormProps","bankAccountTypes","name","value","isFormDisabled","paymentDetails","providerType","providerProps","isHostedPaymentPage","hasReadPropertiesError","readPropertiesMessageError","onStatusChange","paymentFormResult","enabled","actionLabel","allowSaveMethod","data","externalId","setSelectedPaymentAccount","paymentAccount","BankAccountForm","t","paymentAccounts","isLoading","loadingPaymentAccounts","pgV1ApiUrl","Boolean","savedMethods","hasSavedMethods","length","selected","setSelected","paymentTokenID","sel","find","s","showOtherForm","isValid","paymentProviderForm","ECheck","items","savedItems","map","m","nickname","paymentToken","routing","routingNumber","label","String","e","target"],"sources":["../../../../src/utilities/form/paymentForm/BankAccountForm.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { UdpFlexbox } from '../../../UI/fluent-web-components/UdpFlexbox';\nimport { UdpRadioGroup } from '../../../UI/fluent-web-components/UdpRadioGroup';\nimport { UdpSpinner } from '../../../UI/fluent-web-components/UdpSpinner';\nimport { usePaymentProviderForm } from './usePaymentProviderForm';\nimport { PaymentDetails, PaymentMethodData } from './AccountPayment.model';\nimport { PaymentTenderTypeEnum } from '../../../enums/paymentTenderTypeEnum';\nimport { PaymentVendorFactoryEnum } from '../../../enums/paymentVendorFactoryEnum';\nimport { useApiQuery } from '../../useApiQuery';\nimport { HostedPaymentError } from './HostedPaymentError';\nimport { NewECheckForm } from './NewECheckForm';\nimport { ConfigService } from '../../../configService';\n\nconst OTHER_RADIO_VALUE = '__other__';\n\ninterface BankAccountFormProps {\n bankAccountTypes?: { name: string; value: string }[];\n isFormDisabled?: boolean;\n paymentDetails: PaymentDetails;\n providerType?: PaymentVendorFactoryEnum | null;\n providerProps?: any;\n isHostedPaymentPage?: boolean | null;\n hasReadPropertiesError?: boolean | null;\n readPropertiesMessageError?: string | null;\n onStatusChange?: (paymentFormResult: any) => void;\n enabled?: boolean | null;\n actionLabel?: string;\n /** When false, the manual eCheck form hides its \"save\" checkbox. */\n allowSaveMethod?: boolean;\n data?: PaymentMethodData;\n externalId?: string;\n setSelectedPaymentAccount?: (paymentAccount: any) => void;\n}\n\n/**\n * eCheck / bank-account branch of the payment form. Mirrors the credit-card\n * branch: radio list of saved accounts when any exist + \"Other / new account\"\n * option per D3, otherwise renders the appropriate entry form directly.\n */\nexport const BankAccountForm = ({\n bankAccountTypes = [],\n data,\n externalId,\n isFormDisabled = false,\n providerType = null,\n providerProps = null,\n paymentDetails,\n isHostedPaymentPage,\n hasReadPropertiesError,\n readPropertiesMessageError,\n onStatusChange,\n actionLabel,\n allowSaveMethod = true,\n setSelectedPaymentAccount,\n}: BankAccountFormProps) => {\n const { t } = useTranslation();\n\n const { data: paymentAccounts, isLoading: loadingPaymentAccounts } = useApiQuery<any[]>(\n ConfigService.pgV1ApiUrl,\n `PaymentTokenECheck/${externalId}`,\n {},\n { enabled: Boolean(externalId) },\n );\n\n const savedMethods = paymentAccounts ?? [];\n const hasSavedMethods = savedMethods.length > 0;\n\n const [selected, setSelected] = useState<string>(OTHER_RADIO_VALUE);\n\n useEffect(() => {\n setSelected(savedMethods[0]?.paymentTokenID || OTHER_RADIO_VALUE);\n }, [savedMethods]);\n\n useEffect(() => {\n if (selected && selected !== OTHER_RADIO_VALUE) {\n const sel = savedMethods.find((s: any) => s?.paymentTokenID === selected);\n setSelectedPaymentAccount?.(sel || null);\n } else {\n setSelectedPaymentAccount?.(null);\n }\n }, [selected, savedMethods, setSelectedPaymentAccount]);\n\n const showOtherForm = selected === OTHER_RADIO_VALUE;\n\n useEffect(() => {\n if (!showOtherForm) {\n onStatusChange?.({ isValid: true });\n return;\n }\n if (isHostedPaymentPage === false) {\n onStatusChange?.({ isValid: true });\n } else {\n onStatusChange?.({ isValid: false });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showOtherForm, isHostedPaymentPage]);\n\n const paymentProviderForm = usePaymentProviderForm(\n PaymentTenderTypeEnum.ECheck,\n providerType,\n providerProps,\n onStatusChange,\n paymentDetails,\n data,\n );\n\n const items = useMemo(() => {\n const savedItems = savedMethods.map((m: any) => {\n const nickname = m?.paymentToken?.nickname ?? t('Saved account');\n const routing = m?.routingNumber ? ` (${m.routingNumber})` : '';\n return {\n label: `${nickname}${routing}`,\n value: String(m?.paymentTokenID ?? ''),\n };\n });\n return [\n ...savedItems,\n {\n label: actionLabel || t('Use a different account'),\n value: OTHER_RADIO_VALUE,\n },\n ];\n }, [savedMethods, actionLabel, t]);\n\n if (loadingPaymentAccounts) {\n return (\n <UdpFlexbox direction=\"row\" justify=\"center\" align=\"center\">\n <UdpSpinner size=\"medium\" />\n </UdpFlexbox>\n );\n }\n\n if (hasReadPropertiesError) {\n return (\n <HostedPaymentError\n error={t('Configuration error')}\n message={readPropertiesMessageError || t('Unknown error')}\n />\n );\n }\n\n return (\n <UdpFlexbox direction=\"column\" gap=\"sm\" wrap=\"nowrap\">\n {hasSavedMethods && (\n <UdpRadioGroup\n label={t('Saved accounts')}\n name=\"savedBankAccount\"\n orientation=\"vertical\"\n disabled={isFormDisabled}\n value={selected}\n items={items}\n onChange={(e) => setSelected(String(e.target.value))}\n />\n )}\n\n {showOtherForm &&\n (isHostedPaymentPage ? (\n paymentProviderForm\n ) : (\n <NewECheckForm\n isFormDisabled={isFormDisabled}\n bankAccountTypes={bankAccountTypes}\n allowSaveMethod={allowSaveMethod}\n />\n ))}\n </UdpFlexbox>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAMiB,oBAAoB;;;;;;AA0B1B,MAAaqB,mBAAmB,EAC9BnB,mBAAmB,EAAE,EACrBe,MACAC,YACAb,iBAAiB,OACjBE,eAAe,MACfC,gBAAgB,MAChBF,gBACAG,qBACAC,wBACAC,4BACAC,gBACAG,aACAC,kBAAkB,MAClBG,gCAC0B;CAC1B,MAAM,EAAEG,MAAMnC,gBAAgB;CAE9B,MAAM,EAAE8B,MAAMM,iBAAiBC,WAAWC,2BAA2B7B,YACnEG,cAAc2B,YACd,sBAAsBR,cACtB,EAAE,EACF,EAAEJ,SAASa,QAAQT,WAAU,EAC/B,CAAC;CAED,MAAMU,eAAeL,mBAAmB,EAAE;CAC1C,MAAMM,kBAAkBD,aAAaE,SAAS;CAE9C,MAAM,CAACC,UAAUC,eAAe9C,SAAiBc,kBAAkB;AAEnEhB,iBAAgB;AACdgD,cAAYJ,aAAa,IAAIK,kBAAkBjC,kBAAkB;IAChE,CAAC4B,aAAa,C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AY,WAAU;EAAS,KAAI;EAAK,MAAK;EAuBhC,EAtBVO,mBACC,sBAAA,cAAC,eAAD;EACE,OAAOP,EAAE,iBAAiB;EAC1B,MAAK;EACL,aAAY;EACZ,UAAUjB;EACV,OAAO0B;EACAU;EACP,WAAWU,MAAMnB,YAAYkB,OAAOC,EAAEC,OAAOhD,MAAM,CAAC;EAEvD,CAAA,EAEAiC,kBACE5B,sBACC8B,sBAEA,sBAAA,cAAC,eAAD;EACkBlC;EACEH;EACDc;EAEpB,CAAA,EACQ"}
|
|
@@ -6,6 +6,6 @@ interface CashFormProps {
|
|
|
6
6
|
amountValue?: string | number | null | undefined;
|
|
7
7
|
onStatusChange?: (paymentFormResult: boolean) => void;
|
|
8
8
|
}
|
|
9
|
-
export declare const CashForm: ({ isFormDisabled,
|
|
9
|
+
export declare const CashForm: ({ isFormDisabled, amountValue, }: CashFormProps) => React.JSX.Element;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=CashForm.d.ts.map
|