@seamlessdocs/payment-modals 1.0.52 → 1.0.54
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import Select from 'react-select';
|
|
@@ -89,7 +89,7 @@ const validate = values => {
|
|
|
89
89
|
} else if (!/^\d+$/.test(values.accountNumber)) {
|
|
90
90
|
errors.accountNumber = 'Must be a number';
|
|
91
91
|
} else if (
|
|
92
|
-
values.accountNumber.toString().length <
|
|
92
|
+
values.accountNumber.toString().length < 6 ||
|
|
93
93
|
values.accountNumber.toString().length > 12
|
|
94
94
|
) {
|
|
95
95
|
errors.accountNumber = 'Account number structure is not valid';
|
|
@@ -99,6 +99,18 @@ const validate = values => {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
const ACHForm = ({ onPay }) => {
|
|
102
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
103
|
+
const onSubmit = values => {
|
|
104
|
+
setIsSubmitting(true); // avoid multiple clicks
|
|
105
|
+
onPay(
|
|
106
|
+
values.firstName,
|
|
107
|
+
values.lastName,
|
|
108
|
+
values.routingNumber,
|
|
109
|
+
values.accountNumber,
|
|
110
|
+
values.accountType.value,
|
|
111
|
+
() => setIsSubmitting(false)
|
|
112
|
+
);
|
|
113
|
+
};
|
|
102
114
|
return (
|
|
103
115
|
<Formik
|
|
104
116
|
initialValues={{
|
|
@@ -109,15 +121,7 @@ const ACHForm = ({ onPay }) => {
|
|
|
109
121
|
accountType: null
|
|
110
122
|
}}
|
|
111
123
|
validate={validate}
|
|
112
|
-
onSubmit={
|
|
113
|
-
onPay(
|
|
114
|
-
values.firstName,
|
|
115
|
-
values.lastName,
|
|
116
|
-
values.routingNumber,
|
|
117
|
-
values.accountNumber,
|
|
118
|
-
values.accountType.value
|
|
119
|
-
);
|
|
120
|
-
}}
|
|
124
|
+
onSubmit={onSubmit}
|
|
121
125
|
>
|
|
122
126
|
{({ isValid, submitCount, setFieldValue, setFieldTouched }) => (
|
|
123
127
|
<Form>
|
|
@@ -166,7 +170,7 @@ const ACHForm = ({ onPay }) => {
|
|
|
166
170
|
</FieldContainer>
|
|
167
171
|
</div>
|
|
168
172
|
|
|
169
|
-
<button className={styles.submitBtn} type="submit">
|
|
173
|
+
<button className={styles.submitBtn} type="submit" disabled={isSubmitting}>
|
|
170
174
|
<img className={styles.lockIcon} src={lockIcon} alt="lock payment" />
|
|
171
175
|
Authorize Payment
|
|
172
176
|
</button>
|