|
|
|
@ -1,8 +1,8 @@ |
|
|
|
import { useRouteMatch } from 'react-router-dom' |
|
|
|
import { useRouteMatch } from 'react-router-dom' |
|
|
|
import { |
|
|
|
import { |
|
|
|
CardNumberElement, |
|
|
|
|
|
|
|
CardExpiryElement, |
|
|
|
|
|
|
|
CardCvcElement, |
|
|
|
CardCvcElement, |
|
|
|
|
|
|
|
CardExpiryElement, |
|
|
|
|
|
|
|
CardNumberElement, |
|
|
|
} from '@stripe/react-stripe-js' |
|
|
|
} from '@stripe/react-stripe-js' |
|
|
|
|
|
|
|
|
|
|
|
import { isMobileDevice } from 'config/userAgent' |
|
|
|
import { isMobileDevice } from 'config/userAgent' |
|
|
|
@ -16,7 +16,8 @@ import { SolidButton } from 'features/UserAccount/styled' |
|
|
|
import { ElementContainer } from '../ElementContainer' |
|
|
|
import { ElementContainer } from '../ElementContainer' |
|
|
|
|
|
|
|
|
|
|
|
import type { Props } from './hooks' |
|
|
|
import type { Props } from './hooks' |
|
|
|
import { useFormSubmit, ElementTypes } from './hooks' |
|
|
|
import { ElementTypes, useFormSubmit } from './hooks' |
|
|
|
|
|
|
|
import { USA_ID } from './hooks/useCountries' |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
Form, |
|
|
|
Form, |
|
|
|
@ -81,8 +82,9 @@ export const AddCardFormInner = (props: Props) => { |
|
|
|
loader, |
|
|
|
loader, |
|
|
|
name, |
|
|
|
name, |
|
|
|
onAddressChange, |
|
|
|
onAddressChange, |
|
|
|
|
|
|
|
onChangeCountry, |
|
|
|
onCityChange, |
|
|
|
onCityChange, |
|
|
|
onCountryChange, |
|
|
|
onCountrySelect, |
|
|
|
onInputsBlur, |
|
|
|
onInputsBlur, |
|
|
|
onInputsChange, |
|
|
|
onInputsChange, |
|
|
|
onInputsFocus, |
|
|
|
onInputsFocus, |
|
|
|
@ -91,11 +93,12 @@ export const AddCardFormInner = (props: Props) => { |
|
|
|
onStateSelect, |
|
|
|
onStateSelect, |
|
|
|
selectedCountry, |
|
|
|
selectedCountry, |
|
|
|
selectedState, |
|
|
|
selectedState, |
|
|
|
|
|
|
|
typedCountry, |
|
|
|
usaStates, |
|
|
|
usaStates, |
|
|
|
usaStateValue, |
|
|
|
usaStateValue, |
|
|
|
} = useFormSubmit(props) |
|
|
|
} = useFormSubmit(props) |
|
|
|
|
|
|
|
|
|
|
|
const isUsaCountry = selectedCountry?.id === 194 |
|
|
|
const isUsaCountry = selectedCountry?.id === USA_ID |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Form onSubmit={handleSubmit}> |
|
|
|
<Form onSubmit={handleSubmit}> |
|
|
|
@ -166,14 +169,20 @@ export const AddCardFormInner = (props: Props) => { |
|
|
|
<Column> |
|
|
|
<Column> |
|
|
|
<CountryWrapper> |
|
|
|
<CountryWrapper> |
|
|
|
<CustomCombobox |
|
|
|
<CustomCombobox |
|
|
|
value={selectedCountry?.name || ''} |
|
|
|
value={selectedCountry?.name || typedCountry} |
|
|
|
labelLexic={selectedCountry?.name ? '' : 'country'} |
|
|
|
labelLexic={ |
|
|
|
onSelect={onCountryChange} |
|
|
|
(selectedCountry?.name || typedCountry) |
|
|
|
|
|
|
|
|| !isLabelVisible(ElementTypes.CardCountry) |
|
|
|
|
|
|
|
? '' |
|
|
|
|
|
|
|
: 'country' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
onSelect={onCountrySelect} |
|
|
|
onBlur={onInputsBlur(ElementTypes.CardCountry)} |
|
|
|
onBlur={onInputsBlur(ElementTypes.CardCountry)} |
|
|
|
options={countries} |
|
|
|
options={countries} |
|
|
|
withError={false} |
|
|
|
withError={false} |
|
|
|
selected={Boolean(selectedCountry?.name)} |
|
|
|
selected={Boolean(selectedCountry?.name)} |
|
|
|
noSearch |
|
|
|
onChange={onChangeCountry} |
|
|
|
|
|
|
|
onFocus={onInputsFocus(ElementTypes.CardCountry)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</CountryWrapper> |
|
|
|
</CountryWrapper> |
|
|
|
{isUsaCountry && ( |
|
|
|
{isUsaCountry && ( |
|
|
|
|