make max button works during the bond purchase
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
191e1f0c6e
commit
ff9ca1bb79
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.7.26",
|
||||
"version": "0.7.27",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CheckBoxOutlineBlank, CheckBoxOutlined } from "@mui/icons-material";
|
||||
import { Box, Checkbox, FormControlLabel, useMediaQuery } from "@mui/material";
|
||||
import { useState, useMemo } from "react";
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
import { BOND_DEPOSITORY_ADDRESSES } from "../../../constants/addresses";
|
||||
@ -66,7 +66,7 @@ const BondInputArea = ({
|
||||
refetch();
|
||||
}
|
||||
|
||||
const setMax = () => {
|
||||
const setMax = useCallback(() => {
|
||||
if (!balance) return;
|
||||
|
||||
if (bond.capacity.inQuoteToken.lt(bond.maxPayout.inQuoteToken)) {
|
||||
@ -82,12 +82,12 @@ const BondInputArea = ({
|
||||
? bond.maxPayout.inQuoteToken.toString() // Payout is the smallest
|
||||
: balance.toString(),
|
||||
);
|
||||
};
|
||||
}, [bond, balance]);
|
||||
|
||||
const baseTokenString = (bond.maxPayout.inBaseToken.lt(bond.capacity.inBaseToken)
|
||||
const baseTokenString = useMemo(() => (bond.maxPayout.inBaseToken.lt(bond.capacity.inBaseToken)
|
||||
? bond.maxPayout.inBaseToken
|
||||
: bond.capacity.inBaseToken
|
||||
);
|
||||
), [bond]);
|
||||
|
||||
return (
|
||||
<Box minHeight="calc(100vh - 210px)" display="flex" flexDirection="column" justifyContent="center">
|
||||
@ -103,7 +103,7 @@ const BondInputArea = ({
|
||||
token={<TokenStack tokens={bond.quoteToken.icons} sx={{ fontSize: "21px" }} />}
|
||||
tokenName={preparedQuoteToken.name}
|
||||
info={formatCurrency(balance, formatDecimals, preparedQuoteToken.name)}
|
||||
endString={preparedQuoteToken.address && "Max"}
|
||||
endString="Max"
|
||||
endStringOnClick={setMax}
|
||||
value={amount}
|
||||
onChange={event => setAmount(event.currentTarget.value)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user