Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Simplify error messages (#2217)
Browse files Browse the repository at this point in the history
* Simplify error messages

* Change messages
  • Loading branch information
anxolin authored Jan 20, 2022
1 parent 172b7ce commit eca3a88
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/custom/pages/Claim/InvestmentFlow/InvestOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import { tryParseAmount } from 'state/swap/hooks'
import { calculateInvestmentAmounts, calculatePercentage } from 'state/claim/hooks/utils'

enum ErrorMsgs {
Initial = 'Insufficient balance to cover the selected investment amount. Either modify the investment amount or unselect the investment option to move forward',
Balance = 'Insufficient balance to cover the selected investment amount, please modify the selected amount to move forward',
MaxCost = 'Selected amount is higher than available investment amount, please modify the input amount to move forward',
InsufficientBalance = 'Insufficient balance to cover investment amount',
OverMaxInvestment = `Your investment amount can't be above the maximum investment allowed`,
}

export default function InvestOption({ approveData, claim, optionIndex }: InvestOptionProps) {
Expand Down Expand Up @@ -80,8 +79,8 @@ export default function InvestOption({ approveData, claim, optionIndex }: Invest

let errorMsg = null

if (parsedAmount.greaterThan(maxCost)) errorMsg = ErrorMsgs.MaxCost
else if (parsedAmount.greaterThan(balance)) errorMsg = ErrorMsgs.Balance
if (parsedAmount.greaterThan(maxCost)) errorMsg = ErrorMsgs.OverMaxInvestment
else if (parsedAmount.greaterThan(balance)) errorMsg = ErrorMsgs.InsufficientBalance

if (errorMsg) {
setInputError(errorMsg)
Expand Down Expand Up @@ -136,7 +135,7 @@ export default function InvestOption({ approveData, claim, optionIndex }: Invest
}

if (balance.lessThan(maxCost)) {
setInputError(ErrorMsgs.Initial)
setInputError(ErrorMsgs.InsufficientBalance)
} else {
setMaxAmount()
}
Expand Down

0 comments on commit eca3a88

Please sign in to comment.