add checkbox if warmup exists during bond purchase
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
650feb01d7
commit
d9aff4dc6a
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.28",
|
"version": "0.7.29",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Box, Typography } from "@mui/material";
|
import { Box, Typography, Checkbox, FormControlLabel } from "@mui/material";
|
||||||
|
import { CheckBoxOutlineBlank, CheckBoxOutlined } from "@mui/icons-material";
|
||||||
import { styled, useTheme } from "@mui/material/styles";
|
import { styled, useTheme } from "@mui/material/styles";
|
||||||
import SettingsIcon from '@mui/icons-material/Settings';
|
import SettingsIcon from '@mui/icons-material/Settings';
|
||||||
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
||||||
@ -10,13 +11,14 @@ import Metric from "../../../components/Metric/Metric";
|
|||||||
import Modal from "../../../components/Modal/Modal";
|
import Modal from "../../../components/Modal/Modal";
|
||||||
import TokenStack from "../../../components/TokenStack/TokenStack";
|
import TokenStack from "../../../components/TokenStack/TokenStack";
|
||||||
import DataRow from "../../../components/DataRow/DataRow";
|
import DataRow from "../../../components/DataRow/DataRow";
|
||||||
import { PrimaryButton } from "../../../components/Button";
|
import { PrimaryButton, SecondaryButton } from "../../../components/Button";
|
||||||
|
|
||||||
import BondDiscount from "./BondDiscount";
|
import BondDiscount from "./BondDiscount";
|
||||||
import BondVesting from "./BondVesting";
|
import BondVesting from "./BondVesting";
|
||||||
import BondSlippage from "./BondSlippage";
|
import BondSlippage from "./BondSlippage";
|
||||||
|
|
||||||
import { purchaseBond } from "../../../hooks/bonds";
|
import { purchaseBond } from "../../../hooks/bonds";
|
||||||
|
import { useWarmupLength } from "../../../hooks/staking";
|
||||||
|
|
||||||
const StyledBox = styled(Box, {
|
const StyledBox = styled(Box, {
|
||||||
shouldForwardProp: prop => prop !== "template",
|
shouldForwardProp: prop => prop !== "template",
|
||||||
@ -43,8 +45,57 @@ const BondConfirmModal = ({
|
|||||||
handleConfirmClose
|
handleConfirmClose
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
|
const { warmupLength, warmupExists: needsWarmup } = useWarmupLength(chainId);
|
||||||
|
const [acknowledgedWarmup, setAcknowledgedWarmup] = useState(false);
|
||||||
const [isPending, setIsPending] = useState(false);
|
const [isPending, setIsPending] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => setAcknowledgedWarmup(acknowledgedWarmup || !needsWarmup), [acknowledgedWarmup, needsWarmup]);
|
||||||
|
|
||||||
|
const AcknowledgeWarmupCheckbox = () => {
|
||||||
|
if (!needsWarmup) return <></>;
|
||||||
|
return (
|
||||||
|
<Box sx={{ marginBottom: "1rem" }}>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
data-testid="acknowledge-bond-warmup"
|
||||||
|
checked={acknowledgedWarmup}
|
||||||
|
onChange={event => setAcknowledgedWarmup(event.target.checked)}
|
||||||
|
icon={<CheckBoxOutlineBlank viewBox="0 0 24 24" />}
|
||||||
|
checkedIcon={<CheckBoxOutlined viewBox="0 0 24 24" />}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
<Typography variant="body2">
|
||||||
|
{`I understand the ${bondQuoteTokenName} I’m bonding will only be available to claim ${warmupLength.toString()} epochs after my transaction is confirmed, and the warmup extends with each bond purchase`}
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const NeedsWarmupDetails = () => {
|
||||||
|
if (!needsWarmup) return <></>;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AcknowledgeWarmupCheckbox />
|
||||||
|
<SecondaryButton
|
||||||
|
fullWidth
|
||||||
|
href="https://ghostchain.io/ghostdao_litepaper"
|
||||||
|
>
|
||||||
|
Why is there a warmup?
|
||||||
|
</SecondaryButton>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirmCloseMaster = () => {
|
||||||
|
setAcknowledgedWarmup(false);
|
||||||
|
handleConfirmClose()
|
||||||
|
}
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
|
|
||||||
@ -68,7 +119,7 @@ const BondConfirmModal = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
setIsPending(false);
|
setIsPending(false);
|
||||||
handleConfirmClose();
|
handleConfirmCloseMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -84,7 +135,7 @@ const BondConfirmModal = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
onClose={!isPending && handleConfirmClose}
|
onClose={!isPending && handleConfirmCloseMaster}
|
||||||
topLeft={<GhostStyledIcon viewBox="0 0 23 23" component={SettingsIcon} style={{ cursor: "pointer" }} onClick={handleSettingsOpen} />}
|
topLeft={<GhostStyledIcon viewBox="0 0 23 23" component={SettingsIcon} style={{ cursor: "pointer" }} onClick={handleSettingsOpen} />}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
@ -110,9 +161,13 @@ const BondConfirmModal = ({
|
|||||||
<DataRow title="ROI" balance={<BondDiscount discount={bond.discount} textOnly />} />
|
<DataRow title="ROI" balance={<BondDiscount discount={bond.discount} textOnly />} />
|
||||||
<DataRow title="Bond Slippage" balance={<BondSlippage slippage={slippage} textOnly />} />
|
<DataRow title="Bond Slippage" balance={<BondSlippage slippage={slippage} textOnly />} />
|
||||||
<DataRow title="Vesting Term" balance={<BondVesting vesting={bond.vesting} />} />
|
<DataRow title="Vesting Term" balance={<BondVesting vesting={bond.vesting} />} />
|
||||||
<PrimaryButton fullWidth onClick={onSubmit} disabled={isPending} loading={isPending}>
|
{!acknowledgedWarmup && <Box>
|
||||||
|
<Box mt="21px" mb="21px" borderTop={`1px solid ${theme.colors.gray[500]}`}></Box>
|
||||||
|
<NeedsWarmupDetails />
|
||||||
|
</Box>}
|
||||||
|
{acknowledgedWarmup && <PrimaryButton fullWidth onClick={onSubmit} disabled={isPending} loading={isPending}>
|
||||||
{isPending ? "Bonding..." : "Confirm Bond Purchase"}
|
{isPending ? "Bonding..." : "Confirm Bond Purchase"}
|
||||||
</PrimaryButton>
|
</PrimaryButton>}
|
||||||
</>
|
</>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -32,15 +32,19 @@ const StakeConfirmationModal = (props) => {
|
|||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
data-testid="acknowledge-warmup"
|
data-testid="acknowledge-stake-warmup"
|
||||||
checked={acknowledgedWarmup}
|
checked={acknowledgedWarmup}
|
||||||
onChange={event => setAcknowledgedWarmup(event.target.checked)}
|
onChange={event => setAcknowledgedWarmup(event.target.checked)}
|
||||||
icon={<CheckBoxOutlineBlank viewBox="0 0 24 24" />}
|
icon={<CheckBoxOutlineBlank viewBox="0 0 24 24" />}
|
||||||
checkedIcon={<CheckBoxOutlined viewBox="0 0 24 24" />}
|
checkedIcon={<CheckBoxOutlined viewBox="0 0 24 24" />}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label={`I understand the ${props.ftsoSymbol} I’m staking will only be available to claim ${warmupLength.toString()} epochs after my transaction is confirmed`}
|
label={
|
||||||
/>
|
<Typography variant="body2">
|
||||||
|
{`I understand the ${props.ftsoSymbol} I’m staking will only be available to claim ${warmupLength.toString()} epochs after my transaction is confirmed`}
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user