Skip to content

Commit

Permalink
update stake preview
Browse files Browse the repository at this point in the history
  • Loading branch information
lq0-github committed Oct 24, 2024
1 parent 4254b40 commit d1b9ef8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion screens/Staking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const Staking = () => {
<CustomButton
onClick={() => setModal({ name: "staking" })}
className="w-full"
disabled={!total}
// disabled={!total}
>
Stake
</CustomButton>
Expand Down
20 changes: 12 additions & 8 deletions screens/Staking/modalStaking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,34 @@ const ModalStaking = ({ isOpen, onClose }) => {
.replace(/(?!^)-/g, "")
.replace(/^0+(\d)/gm, "$1");

const sliderValue = Math.round((amount * 100) / Number(total)) || 0;
const sliderValue = useMemo(() => {
if (Number(amount) > Number(total)) {
return 100;
}
return Math.round((Number(amount) * 100) / Number(total)) || 0;
}, [amount, total]);

const handleMaxClick = () => {
trackMaxStaking({ total: totalToken });
setAmount(totalToken);
};
const handleInputChange = (e) => {
let { value } = e?.target || {};
const { value } = e?.target || {};
const numRegex = /^([0-9]*\.?[0-9]*$)/;
if (!numRegex.test(value)) {
e.preventDefault();
return;
}
if (Number(value) > Number(total)) {
value = total;
}
setAmount(value);
};

const handleRangeSliderChange = (percent) => {
if (Number(percent) >= 99.7) {
if (percent >= 100) {
setAmount(String(Number(total) * 1.01));
} else if (Number(percent) >= 99.7) {
setAmount(totalToken);
} else {
setAmount((Number(total) * percent) / 100);
setAmount(((Number(total) * percent) / 100).toFixed(8));
}
};

Expand Down Expand Up @@ -208,7 +212,7 @@ const ModalStaking = ({ isOpen, onClose }) => {
isLoading={loadingStake}
className="w-full mt-2 mb-4"
>
Stake
{Number(amount) > Number(total) ? "Insufficient Balance" : "Stake"}
</CustomButton>

<div className="text-primary h5 mb-4 text-center">
Expand Down

0 comments on commit d1b9ef8

Please sign in to comment.