From 8fee31846d47911f0abc93da346514c1bc610cae Mon Sep 17 00:00:00 2001 From: Alexandre Magno Date: Sun, 24 Sep 2023 11:46:11 +0200 Subject: [PATCH] feat: simplifying bank account activation and supporting Iban (#1009) --- .../src/components/payment/payment-options.js | 4 +- .../components/profile/account-details.tsx | 73 +- frontend/src/components/profile/account.js | 908 +++++------------- .../profile/components/account-tabs.tsx | 6 +- modules/users/userAccountCreate.js | 8 +- modules/users/userAccountUpdate.js | 4 +- 6 files changed, 300 insertions(+), 703 deletions(-) diff --git a/frontend/src/components/payment/payment-options.js b/frontend/src/components/payment/payment-options.js index 7b9e6dad9..b7d9ddaac 100644 --- a/frontend/src/components/payment/payment-options.js +++ b/frontend/src/components/payment/payment-options.js @@ -33,8 +33,8 @@ class PaymentOptions extends Component { - - + + diff --git a/frontend/src/components/profile/account-details.tsx b/frontend/src/components/profile/account-details.tsx index 1dc7807c9..b5edb2122 100644 --- a/frontend/src/components/profile/account-details.tsx +++ b/frontend/src/components/profile/account-details.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react' -import { injectIntl, FormattedMessage } from 'react-intl' +import { injectIntl, FormattedMessage, FormattedDate } from 'react-intl' import ReactPlaceholder from 'react-placeholder' import { withStyles, @@ -16,6 +16,9 @@ import { import MuiAlert from '@material-ui/lab/Alert' import 'react-phone-number-input/style.css' import MaskedInput from 'react-text-mask' +import Moment from 'moment' +import FormControlLabel from '@material-ui/core/FormControlLabel' +import Switch from '@material-ui/core/Switch' import CountryPicker, { countryCodes } from './country-picker' @@ -83,15 +86,9 @@ export const Field = ({ ref, name, value, label, type = 'text', required = false const AccountDetails = ({ intl, account, - history, updateAccount, user, - updateUser, - deleteUser, createAccount, - createBankAccount, - getBankAccount, - bankAccount, fetchAccount, classes }) => { @@ -99,6 +96,7 @@ const AccountDetails = ({ const [ displayCurrentCountry, setDisplayCurrentCountry ] = useState({ country: '', code: ''}) const [ userId ] = useState('') const [ openCountryPicker, setOpenCountryPicker ] = useState(false) + const [ terms, setTerms ] = useState(false) const handleSubmit = (e) => { e.preventDefault() @@ -124,6 +122,10 @@ const AccountDetails = ({ 'individual[dob][year]': e.target['individual[dob][year]'].value } + if(terms) { + formData['tos_acceptance[date]'] = Math.round(+new Date() / 1000) + } + if (e.target['individual[id_number]'].value) { formData['individual[id_number]'] = e.target['individual[id_number]'].value @@ -375,6 +377,63 @@ const AccountDetails = ({ +
+ + + + + + + + { !account.data.tos_acceptance.date ? ( + <> + + + {(msg) => ( + setTerms(!terms)} + value={terms} + color='primary' + /> + } + label={msg} + /> + )} + + + + + + {' '} + {' '} + + + + + ) : ( + + + + {' '} + + + + )} + + +
- - - - ) } - { this.state.currentStep === 1 && ( - - - -
- { getStepContent(1) } -
- - - { bankAccount.data.routing_number ? ( - - - - ) : ( - - { user.user.country === 'BR' && ( - - ) } - { this.state.bankNumberError && ( - - { ' ' } - - - ) } - - ) } - + + + + + + {bankAccount.data.routing_number ? ( + + + + ) : ( + + {user.user.country === 'BR' && ( + + )} + {this.state.bankNumberError && ( + + {' '} + + + )} + + )} - - - { (user.user.country !== 'DK' || user.user.country !== 'BE') && ( - - - { (msg) => ( - - ) } - - - ) } + + + {this.state.ibanMode ? ( + - - { (msg) => ( + + {(msg) => ( - ) } + )} - { this.state.AccountNumberError && ( + {this.state.AccountNumberError && ( - { ' ' } + {' '} - ) } + )} - -
- - - - - -
- - ) } - { this.state.currentStep === 2 && ( -
- { !account.data.tos_acceptance.date ? ( -
- - -
- - { getStepContent(2) } - -
- - - - - { ' ' } - { ' ' } - - - - - { (msg) => ( - - } - label={ msg } - /> - ) } - - - - -
- - - - -
-
- ) : ( - - -
- { getStepContent(2) } -
- - - - - - - - -
- - - - -
- ) } -
- ) } - - - - - - - - -
- - - + ) : ( + + {(user.user.country !== 'DK' || user.user.country !== 'BE') && ( - - { (msg) => ( + + {(msg) => ( - ) } + )} + )} + + + {(msg) => ( + + )} + + {this.state.AccountNumberError && ( + + {' '} + + + )} + + + - + ) } + + {user.user.country !== 'BR' && !bankAccount.data.routing_number && ( - - { (msg) => ( - + {(msg) => ( + + } + label={msg} /> - ) } + )} - - - - - - { (msg) => ( - - ) } - - - - - { (msg) => ( - - ) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
+ )}
- -
-
+ + + + + +
) : (
- { !account.data.id && - + {!account.data.id && + - + - { this.state.countryCode && ( + {this.state.countryCode && (
} - label={ this.state.countryLabel } - className={ classes.chip } + avatar={} + label={this.state.countryLabel} + className={classes.chip} />
- ) } + )}
- + - + -
} - +
} +
) } - } - { this.state.currentTab === 1 && + } + {this.state.currentTab === 1 &&
- + -
- +
+ - + - { !user.user.paypal_id ? ( + {!user.user.paypal_id ? ( - { (msg) => ( + {(msg) => ( - ) } + )} ) : (
- +
- ) } + )}
- + @@ -1041,7 +573,7 @@ class Account extends Component { name='paypal_email' type='email' id='email' - style={ { marginRight: 20 } } + style={{ marginRight: 20 }} defaultValue={ user.user.paypal_id ? `${user.user.paypal_id}` : `${user.user.email}` } @@ -1049,15 +581,15 @@ class Account extends Component { - +