-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): rebrand staking overview in homepage (#1911)
* feat: rebrand stake overview homepage * feat: keep constant value as before * feat: remove loading svg and update when is loading * feat: rename file --------- Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>
- Loading branch information
1 parent
f799853
commit 7b85cba
Showing
3 changed files
with
79 additions
and
78 deletions.
There are no files selected for viewing
69 changes: 0 additions & 69 deletions
69
apps/wallet/src/ui/app/pages/home/tokens/TokenIconLink.tsx
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
apps/wallet/src/ui/app/pages/home/tokens/TokenStakingOverview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { ampli } from '_src/shared/analytics/ampli'; | ||
import { | ||
formatDelegatedStake, | ||
useFormatCoin, | ||
useGetDelegatedStake, | ||
useTotalDelegatedStake, | ||
DELEGATED_STAKES_QUERY_REFETCH_INTERVAL, | ||
DELEGATED_STAKES_QUERY_STALE_TIME, | ||
} from '@iota/core'; | ||
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; | ||
import { | ||
Card, | ||
CardAction, | ||
CardActionType, | ||
CardBody, | ||
CardImage, | ||
CardType, | ||
ImageShape, | ||
} from '@iota/apps-ui-kit'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Stake } from '@iota/ui-icons'; | ||
|
||
export function TokenStakingOverview({ | ||
accountAddress, | ||
disabled, | ||
}: { | ||
accountAddress: string; | ||
disabled: boolean; | ||
}) { | ||
const navigate = useNavigate(); | ||
const { data: delegatedStake, isPending } = useGetDelegatedStake({ | ||
address: accountAddress, | ||
staleTime: DELEGATED_STAKES_QUERY_STALE_TIME, | ||
refetchInterval: DELEGATED_STAKES_QUERY_REFETCH_INTERVAL, | ||
}); | ||
|
||
// Total active stake for all delegations | ||
const delegatedStakes = delegatedStake ? formatDelegatedStake(delegatedStake) : []; | ||
const totalDelegatedStake = useTotalDelegatedStake(delegatedStakes); | ||
const [formattedDelegatedStake, symbol, queryResultStake] = useFormatCoin( | ||
totalDelegatedStake, | ||
IOTA_TYPE_ARG, | ||
); | ||
|
||
function handleOnClick() { | ||
navigate('/stake'); | ||
ampli.clickedStakeIota({ | ||
isCurrentlyStaking: totalDelegatedStake > 0, | ||
sourceFlow: 'Home page', | ||
}); | ||
} | ||
|
||
const isLoading = isPending || queryResultStake.isPending; | ||
|
||
return ( | ||
<Card type={CardType.Filled} onClick={handleOnClick} isDisabled={disabled}> | ||
<CardImage shape={ImageShape.SquareRounded}> | ||
<Stake className="h-5 w-5 text-primary-20" /> | ||
</CardImage> | ||
<CardBody | ||
title={ | ||
isLoading | ||
? '--' | ||
: totalDelegatedStake | ||
? `${formattedDelegatedStake} ${symbol}` | ||
: 'Start Staking' | ||
} | ||
subtitle={isLoading ? '--' : totalDelegatedStake ? 'Current Stake' : 'Earn Rewards'} | ||
/> | ||
<CardAction type={CardActionType.Link} onClick={handleOnClick} /> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters