Skip to content

Commit

Permalink
feat(seamless limits): improved logic for buy flow to cover case over…
Browse files Browse the repository at this point in the history
… balance
  • Loading branch information
milan-bc committed Jan 19, 2022
1 parent 340d639 commit 764fbe6
Showing 1 changed file with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {

const showLimitError = showError && amtError === 'ABOVE_MAX_LIMIT'

const isFundsMethod = method && method.type === BSPaymentTypes.FUNDS

return (
<CustomForm onSubmit={props.handleSubmit}>
<FlyoutWrapper style={{ borderBottom: 'grey000', paddingBottom: '0px' }}>
Expand Down Expand Up @@ -635,8 +637,17 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
: `${min} ${Currencies[fiatCurrency].units[fiatCurrency].symbol}`
}}
/>
) : amtError === 'ABOVE_LIMIT' || amtError === 'ABOVE_BALANCE' ? (
) : amtError === 'ABOVE_LIMIT' ||
(amtError === 'ABOVE_BALANCE' && !isFundsMethod) ? (
<FormattedMessage id='copy.over_your_limit' defaultMessage='Over Your Limit' />
) : amtError === 'ABOVE_BALANCE' && isFundsMethod ? (
<FormattedMessage
id='copy.not_enough_coin'
defaultMessage='Not Enough {coin}'
values={{
coin: props.fiatCurrency
}}
/>
) : (
<FormattedMessage
id='copy.above_max'
Expand Down Expand Up @@ -741,7 +752,8 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
}}
/>
)}
{(amtError === 'ABOVE_LIMIT' || true) && (
{(amtError === 'ABOVE_LIMIT' ||
(amtError === 'ABOVE_BALANCE' && !isFundsMethod)) && (
<FormattedMessage
id='modals.simplebuy.checkout.buy.over_limit'
defaultMessage='You can buy up to {amount} per transaction. Upgrade to Gold & buy larger amounts with your bank or card.'
Expand All @@ -753,6 +765,20 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
}}
/>
)}
{amtError === 'ABOVE_BALANCE' && isFundsMethod && (
<FormattedMessage
id='modals.simplebuy.checkout.buy.abovemax'
defaultMessage='The maximum amount of {coin} you can buy with your {currency} {amount}'
values={{
amount:
fix === 'FIAT'
? fiatToString({ unit: props.fiatCurrency, value: max })
: `${min} ${Currencies[fiatCurrency].units[fiatCurrency].symbol}`,
coin: cryptoCurrency,
currency: fiatCurrency
}}
/>
)}
</Text>
</ButtonContainer>
)}
Expand Down Expand Up @@ -807,7 +833,9 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = (props) => {
</FlyoutWrapper>

{props.isSddFlow && props.orderType === OrderType.BUY && <IncreaseLimits {...props} />}
{(props.isSddFlow || amtError === 'ABOVE_BALANCE' || amtError === 'ABOVE_LIMIT') &&
{(props.isSddFlow ||
(amtError === 'ABOVE_BALANCE' && !isFundsMethod) ||
amtError === 'ABOVE_LIMIT') &&
props.orderType === OrderType.BUY && (
<FlyoutWrapper>
<UpgradeToGoldLine
Expand Down

0 comments on commit 764fbe6

Please sign in to comment.