From 441e1b4039937defdf9f60f6ad99d3c90ff7d04e Mon Sep 17 00:00:00 2001 From: evavirseda Date: Thu, 22 Aug 2024 08:43:50 +0200 Subject: [PATCH] feat(wallet): rebrand unstake (#1882) * feat: update view and remove debris * fix build * feat: show - instead of ~0 * feat: update ui components * feat: rebrand staking flow: amount screen * fix type * feat: update selected style * feat: refine unstake view * feat: improvements * feat: refine views * feat: update button style and text * feat: add showBackButton --- .../src/ui/app/staking/stake/StakeForm.tsx | 2 +- .../src/ui/app/staking/stake/StakingCard.tsx | 4 +- .../src/ui/app/staking/stake/UnstakeForm.tsx | 134 +++++++----------- .../app/staking/stake/ValidatorFormDetail.tsx | 34 ++--- .../wallet/src/ui/app/staking/stake/index.tsx | 3 +- 5 files changed, 75 insertions(+), 102 deletions(-) diff --git a/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx b/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx index ae4e98c5da3..36bb2358d71 100644 --- a/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx +++ b/apps/wallet/src/ui/app/staking/stake/StakeForm.tsx @@ -118,7 +118,7 @@ function StakeForm({ validatorAddress, coinBalance, coinType, epoch }: StakeFrom )} /> -
+
diff --git a/apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx b/apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx index d02952eb831..a0c6d5e9522 100644 --- a/apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx +++ b/apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx @@ -2,17 +2,20 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Card } from '_app/shared/card'; -import { Text } from '_app/shared/text'; -import { CountDownTimer } from '_src/ui/app/shared/countdown-timer'; -import { createUnstakeTransaction, useFormatCoin, useGetTimeBeforeEpochNumber } from '@iota/core'; +import { + createUnstakeTransaction, + TimeUnit, + useFormatCoin, + useGetTimeBeforeEpochNumber, + useTimeAgo, +} from '@iota/core'; import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; import { Form } from 'formik'; import { useMemo } from 'react'; import { useActiveAddress, useTransactionGasBudget } from '../../hooks'; import { GAS_SYMBOL } from '../../redux/slices/iota-objects/Coin'; -import { Heading } from '../../shared/heading'; +import { Divider, KeyValueInfo, Panel } from '@iota/apps-ui-kit'; export interface StakeFromProps { stakedIotaId: string; @@ -38,86 +41,53 @@ export function UnStakeForm({ const { data: gasBudget } = useTransactionGasBudget(activeAddress, transaction); const { data: currentEpochEndTime } = useGetTimeBeforeEpochNumber(epoch + 1 || 0); + const currentEpochEndTimeAgo = useTimeAgo({ + timeFrom: currentEpochEndTime, + endLabel: '--', + shortedTimeLabel: false, + shouldEnd: true, + maxTimeUnit: TimeUnit.ONE_HOUR, + }); + + const currentEpochEndTimeFormatted = + currentEpochEndTime > 0 ? currentEpochEndTimeAgo : `Epoch #${epoch}`; return ( -
- - - Current Epoch Ends - -
- {currentEpochEndTime > 0 ? ( - - ) : ( - - Epoch #{epoch} - - )} -
-
- } - footer={ -
- - Total unstaked IOTA - -
- - {totalIota} - - - {GAS_SYMBOL} - -
-
- } - > -
-
- - Your Stake - - - {tokenBalance} {GAS_SYMBOL} - -
-
- - Staking Rewards Earned - - - {rewards} {rewardSymbol} - -
+ + +
+ + + + + +
- -
- -
- - Gas Fees - - - - {gasBudget || '-'} {GAS_SYMBOL} - -
-
-
+
+ +
+ +
+
); } diff --git a/apps/wallet/src/ui/app/staking/stake/ValidatorFormDetail.tsx b/apps/wallet/src/ui/app/staking/stake/ValidatorFormDetail.tsx index e4be6021431..e4da11992ff 100644 --- a/apps/wallet/src/ui/app/staking/stake/ValidatorFormDetail.tsx +++ b/apps/wallet/src/ui/app/staking/stake/ValidatorFormDetail.tsx @@ -115,33 +115,35 @@ export function ValidatorFormDetail({ validatorAddress, unstake }: ValidatorForm
{!unstake && ( - + <> + + + )} -
diff --git a/apps/wallet/src/ui/app/staking/stake/index.tsx b/apps/wallet/src/ui/app/staking/stake/index.tsx index 6edc1110fd2..4add0478403 100644 --- a/apps/wallet/src/ui/app/staking/stake/index.tsx +++ b/apps/wallet/src/ui/app/staking/stake/index.tsx @@ -14,13 +14,14 @@ function StakePage() { const unstake = searchParams.get('unstake') === 'true'; const navigate = useNavigate(); - const stakingTitle = unstake ? 'Unstake IOTA' : 'Stake IOTA'; + const stakingTitle = unstake ? 'Unstake' : 'Stake IOTA'; return ( navigate('/')} + showBackButton > {validatorAddress ? : }