make max button works during the bond purchase

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-04-28 13:49:24 +03:00
parent 191e1f0c6e
commit ff9ca1bb79
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.7.26",
"version": "0.7.27",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -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)}