Skip to content

Commit

Permalink
feat(withdraw fee): prevent user from withdraw in case that balance i…
Browse files Browse the repository at this point in the history
…s lower than currency fee
  • Loading branch information
milan-bc committed Sep 28, 2020
1 parent 29c520c commit e98db67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@ export const getData = (state: RootState, ownProps: OwnProps) => {
state,
ownProps.fiatCurrency
)
const feesR = selectors.components.withdraw.getFeeForCurrency(
state,
ownProps.fiatCurrency
)

return lift(
(
balance: ExtractSuccess<typeof balanceR>,
defaultBeneficiary: ExtractSuccess<typeof defaultBeneficiaryR>,
userData: ExtractSuccess<typeof userDataR>,
minAmount: ExtractSuccess<typeof minAmountR>
minAmount: ExtractSuccess<typeof minAmountR>,
fees: ExtractSuccess<typeof feesR>
) => ({
balance,
defaultBeneficiary,
formErrors,
userData,
minAmount
minAmount,
fees
})
)(balanceR, defaultBeneficiaryR, userDataR, minAmountR)
)(balanceR, defaultBeneficiaryR, userDataR, minAmountR, feesR)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const Success: React.FC<InjectedFormProps<
const amtError =
typeof props.formErrors.amount === 'string' && props.formErrors.amount

const userCanWithdraw = Number(props.balance) > Number(props.fees.value)

return (
<FlyoutWrapper>
<Top>
Expand Down Expand Up @@ -214,7 +216,7 @@ const Success: React.FC<InjectedFormProps<
</ToContainer>
<ActionContainer>
<Button
disabled={props.invalid || !beneficiary}
disabled={props.invalid || !beneficiary || !userCanWithdraw}
data-e2e='withdrawNext'
type='submit'
nature='primary'
Expand Down

0 comments on commit e98db67

Please sign in to comment.