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