Added max button.

This commit is contained in:
Leonard Ge 2020-12-24 18:53:00 +08:00 committed by Armani Ferrante
parent 0dc1ae1590
commit 7f9d8daba4
1 changed files with 18 additions and 5 deletions

View File

@ -464,9 +464,18 @@ function useForm(balanceInfo, addressHelperText, passAddressValidation) {
margin="normal"
type="number"
InputProps={{
endAdornment: tokenSymbol ? (
<InputAdornment position="end">{tokenSymbol}</InputAdornment>
) : null,
endAdornment: (
<InputAdornment position="end">
<Button onClick={() =>
setTransferAmountString(
balanceAmountToUserAmount(balanceAmount, decimals),
)
}>
MAX
</Button>
{tokenSymbol ? tokenSymbol : null}
</InputAdornment>
),
inputProps: {
step: Math.pow(10, -decimals),
},
@ -477,11 +486,11 @@ function useForm(balanceInfo, addressHelperText, passAddressValidation) {
<span
onClick={() =>
setTransferAmountString(
(balanceAmount / Math.pow(10, decimals)).toFixed(decimals),
balanceAmountToUserAmount(balanceAmount, decimals),
)
}
>
Max: {balanceAmount / Math.pow(10, decimals)}
Max: {balanceAmountToUserAmount(balanceAmount, decimals)}
</span>
}
/>
@ -497,6 +506,10 @@ function useForm(balanceInfo, addressHelperText, passAddressValidation) {
};
}
function balanceAmountToUserAmount(balanceAmount, decimals) {
return (balanceAmount / Math.pow(10, decimals)).toFixed(decimals)
}
function EthWithdrawalCompleter({ ethAccount, publicKey }) {
const [swaps] = useSwapApiGet(`swaps_from/sol/${publicKey.toBase58()}`, {
refreshInterval: 10000,