From 4a30f406d24f667b2a3c052cbddcc85bcba6a1cb Mon Sep 17 00:00:00 2001 From: Jeremy <168515712+jeremy-babylonlabs@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:51:39 +0800 Subject: [PATCH] disable form when no fp selected (#495) --- src/app/components/Staking/Form/StakingAmount.tsx | 8 ++++++-- src/app/components/Staking/Form/StakingTime.tsx | 4 ++++ src/app/components/Staking/Staking.tsx | 13 +++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/app/components/Staking/Form/StakingAmount.tsx b/src/app/components/Staking/Form/StakingAmount.tsx index 97b56a05..cf180554 100644 --- a/src/app/components/Staking/Form/StakingAmount.tsx +++ b/src/app/components/Staking/Form/StakingAmount.tsx @@ -13,6 +13,7 @@ interface StakingAmountProps { btcWalletBalanceSat?: number; onStakingAmountSatChange: (inputAmountSat: number) => void; reset: boolean; + disabled?: boolean; } export const StakingAmount: React.FC = ({ @@ -21,6 +22,7 @@ export const StakingAmount: React.FC = ({ btcWalletBalanceSat, onStakingAmountSatChange, reset, + disabled = false, }) => { const [value, setValue] = useState(""); const [error, setError] = useState(""); @@ -127,13 +129,15 @@ export const StakingAmount: React.FC = ({
diff --git a/src/app/components/Staking/Form/StakingTime.tsx b/src/app/components/Staking/Form/StakingTime.tsx index 42eb1b45..00bd39d8 100644 --- a/src/app/components/Staking/Form/StakingTime.tsx +++ b/src/app/components/Staking/Form/StakingTime.tsx @@ -9,6 +9,7 @@ interface StakingTimeProps { unbondingTimeBlocks: number; onStakingTimeBlocksChange: (inputTimeBlocks: number) => void; reset: boolean; + disabled?: boolean; } export const StakingTime: React.FC = ({ @@ -16,6 +17,7 @@ export const StakingTime: React.FC = ({ maxStakingTimeBlocks, onStakingTimeBlocksChange, reset, + disabled = false, }) => { const [value, setValue] = useState(""); const [error, setError] = useState(""); @@ -112,11 +114,13 @@ export const StakingTime: React.FC = ({ className={twJoin( `no-focus input input-bordered w-full`, error && "input-error", + disabled && "opacity-50 cursor-not-allowed", )} value={value} onChange={handleChange} onBlur={handleBlur} placeholder="Blocks" + disabled={disabled} />

{error}

diff --git a/src/app/components/Staking/Staking.tsx b/src/app/components/Staking/Staking.tsx index 499e2343..c2cd905c 100644 --- a/src/app/components/Staking/Staking.tsx +++ b/src/app/components/Staking/Staking.tsx @@ -432,7 +432,7 @@ export const Staking = () => { return (
-
+
Step 2 @@ -464,13 +464,21 @@ export const Staking = () => {
-
+
+
{ btcWalletBalanceSat={btcWalletBalanceSat} onStakingAmountSatChange={handleStakingAmountSatChange} reset={resetFormInputs} + disabled={!finalityProvider} /> {signReady && (