@seamlessdocs/payment-modals 1.0.51 → 1.0.53

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamlessdocs/payment-modals",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "Payment modals for SeamlessDocs",
5
5
  "main": "build/payment-modals.js",
6
6
  "repository": {
@@ -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';
@@ -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={values => {
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>
@@ -50,7 +50,7 @@ const ACHPaymentModal = ({
50
50
  {' submission + '}
51
51
  <currency>$</currency>
52
52
  <money>{Number(feeAmount).toFixed(2)}</money>
53
- {feeName}
53
+ {` ${feeName || 'additional fee'}`}
54
54
  </div>
55
55
  )}
56
56
  </div>