From 2725997c3cde58550484be7b709b57480d029965 Mon Sep 17 00:00:00 2001 From: Branko Date: Wed, 11 Dec 2024 15:55:32 +0100 Subject: [PATCH 1/3] fix: improve stake wizzard --- .../components/Dialogs/Staking/StakeDialog.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx index 473429865fc..ab0186a53f9 100644 --- a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx +++ b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx @@ -107,7 +107,12 @@ export function StakeDialog({ } function detailsHandleStake() { - setView?.(StakeDialogView.SelectValidator); + setSelectedValidator?.(stakedDetails?.validatorAddress ?? ''); + setView?.( + isTimelockedStaking + ? StakeDialogView.EnterTimelockedAmount + : StakeDialogView.EnterAmount, + ); } function handleTransactionSuccess(digest: string) { From d4f1476dba2b2b919b1bee4345f501bcfcca47a6 Mon Sep 17 00:00:00 2001 From: Branko Date: Wed, 11 Dec 2024 21:01:27 +0100 Subject: [PATCH 2/3] fix: add set view helper function --- .../Dialogs/Staking/StakeDialog.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx index ab0186a53f9..54adc93c457 100644 --- a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx +++ b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx @@ -89,36 +89,36 @@ export function StakeDialog({ const validators = Object.keys(rollingAverageApys ?? {}) ?? []; function handleBack(): void { - setView?.(StakeDialogView.SelectValidator); + setView(StakeDialogView.SelectValidator); } function handleValidatorSelect(validator: string): void { setSelectedValidator?.(validator); } + function setViewBasedOnStakingType() { + setView( + isTimelockedStaking + ? StakeDialogView.EnterTimelockedAmount + : StakeDialogView.EnterAmount, + ); + } + function selectValidatorHandleNext(): void { if (selectedValidator) { - setView?.( - isTimelockedStaking - ? StakeDialogView.EnterTimelockedAmount - : StakeDialogView.EnterAmount, - ); + setViewBasedOnStakingType(); } } function detailsHandleStake() { setSelectedValidator?.(stakedDetails?.validatorAddress ?? ''); - setView?.( - isTimelockedStaking - ? StakeDialogView.EnterTimelockedAmount - : StakeDialogView.EnterAmount, - ); + setViewBasedOnStakingType(); } function handleTransactionSuccess(digest: string) { onSuccess?.(digest); setTxDigest(digest); - setView?.(StakeDialogView.TransactionDetails); + setView(StakeDialogView.TransactionDetails); } return ( From f788ed13c6ee5716a861878aabb047c454b592dd Mon Sep 17 00:00:00 2001 From: Branko Date: Thu, 12 Dec 2024 10:50:39 +0100 Subject: [PATCH 3/3] fix: add check for stake details --- .../components/Dialogs/Staking/StakeDialog.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx index 54adc93c457..7aad7b722b7 100644 --- a/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx +++ b/apps/wallet-dashboard/components/Dialogs/Staking/StakeDialog.tsx @@ -111,8 +111,10 @@ export function StakeDialog({ } function detailsHandleStake() { - setSelectedValidator?.(stakedDetails?.validatorAddress ?? ''); - setViewBasedOnStakingType(); + if (stakedDetails) { + setSelectedValidator?.(stakedDetails.validatorAddress); + setViewBasedOnStakingType(); + } } function handleTransactionSuccess(digest: string) {