@open-tender/utils 0.1.42 → 0.1.44
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/cjs/hooks/useCreditCard.js +1 -1
- package/dist/cjs/hooks/useDonationForm.d.ts +1 -1
- package/dist/cjs/hooks/useDonationForm.js +2 -1
- package/dist/esm/hooks/useCreditCard.js +1 -1
- package/dist/esm/hooks/useDonationForm.d.ts +1 -1
- package/dist/esm/hooks/useDonationForm.js +2 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ const useCreditCard = (initState, cardErrors = {}, disabled = false) => {
|
|
|
17
17
|
const [cardType, setCardType] = (0, react_1.useState)(initCardType || 'OTHER');
|
|
18
18
|
const [errors, setErrors] = (0, react_1.useState)(cardErrors);
|
|
19
19
|
const { acct, exp, cvv, zip } = data;
|
|
20
|
-
const isComplete = acct && exp && cvv && zip &&
|
|
20
|
+
const isComplete = acct && exp && cvv && zip && (0, __1.isEmpty)(errors) ? true : false;
|
|
21
21
|
const handleChange = (name, value) => {
|
|
22
22
|
if (name === 'acct') {
|
|
23
23
|
const currentType = (0, __1.getCardType)(value.replace(/\s/g, ''));
|
|
@@ -22,7 +22,7 @@ export declare const useDonationsForm: (purchase: (data: DonationPurchase, callb
|
|
|
22
22
|
value: unknown;
|
|
23
23
|
}[];
|
|
24
24
|
handleCreditCard: (value: string) => void;
|
|
25
|
-
handleSubmit: () => void;
|
|
25
|
+
handleSubmit: (evt: React.FormEvent<HTMLFormElement>) => void;
|
|
26
26
|
handleReset: () => void;
|
|
27
27
|
setErrors: import("react").Dispatch<import("react").SetStateAction<Record<string, string>>>;
|
|
28
28
|
};
|
|
@@ -108,8 +108,9 @@ const useDonationsForm = (purchase, reset, setAlert, loading, error, success, cu
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
const handleSubmit = () => {
|
|
111
|
+
const handleSubmit = (evt) => {
|
|
112
112
|
var _a, _b, _c;
|
|
113
|
+
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
113
114
|
if (!amount || !email) {
|
|
114
115
|
setErrors({ form: 'Both amount and email are required' });
|
|
115
116
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && inputRef.current.focus();
|
|
@@ -14,7 +14,7 @@ export const useCreditCard = (initState, cardErrors = {}, disabled = false) => {
|
|
|
14
14
|
const [cardType, setCardType] = useState(initCardType || 'OTHER');
|
|
15
15
|
const [errors, setErrors] = useState(cardErrors);
|
|
16
16
|
const { acct, exp, cvv, zip } = data;
|
|
17
|
-
const isComplete = acct && exp && cvv && zip &&
|
|
17
|
+
const isComplete = acct && exp && cvv && zip && isEmpty(errors) ? true : false;
|
|
18
18
|
const handleChange = (name, value) => {
|
|
19
19
|
if (name === 'acct') {
|
|
20
20
|
const currentType = getCardType(value.replace(/\s/g, ''));
|
|
@@ -22,7 +22,7 @@ export declare const useDonationsForm: (purchase: (data: DonationPurchase, callb
|
|
|
22
22
|
value: unknown;
|
|
23
23
|
}[];
|
|
24
24
|
handleCreditCard: (value: string) => void;
|
|
25
|
-
handleSubmit: () => void;
|
|
25
|
+
handleSubmit: (evt: React.FormEvent<HTMLFormElement>) => void;
|
|
26
26
|
handleReset: () => void;
|
|
27
27
|
setErrors: import("react").Dispatch<import("react").SetStateAction<Record<string, string>>>;
|
|
28
28
|
};
|
|
@@ -105,8 +105,9 @@ export const useDonationsForm = (purchase, reset, setAlert, loading, error, succ
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
|
-
const handleSubmit = () => {
|
|
108
|
+
const handleSubmit = (evt) => {
|
|
109
109
|
var _a, _b, _c;
|
|
110
|
+
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
110
111
|
if (!amount || !email) {
|
|
111
112
|
setErrors({ form: 'Both amount and email are required' });
|
|
112
113
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && inputRef.current.focus();
|
package/package.json
CHANGED