-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1233 from alephium/redesign-dw
Basic tokens details modal
- Loading branch information
Showing
34 changed files
with
360 additions
and
158 deletions.
There are no files selected for viewing
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
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
apps/desktop-wallet/src/api/apiDataHooks/wallet/useFetchWalletTokensByType.ts
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
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
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
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
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
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
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
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,34 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import styled, { useTheme } from 'styled-components' | ||
|
||
import useFetchWalletSingleTokenBalances from '@/api/apiDataHooks/wallet/useFetchWalletSingleTokenBalances' | ||
import Amount, { TokenAmountProps } from '@/components/Amount' | ||
|
||
const FTAmounts = (props: Omit<TokenAmountProps, 'value'>) => { | ||
const { data: balances, isLoading } = useFetchWalletSingleTokenBalances({ tokenId: props.tokenId }) | ||
const { t } = useTranslation() | ||
const theme = useTheme() | ||
|
||
const totalBalance = BigInt(balances.totalBalance) | ||
const availableBalance = BigInt(balances.availableBalance) | ||
|
||
return ( | ||
<> | ||
{totalBalance && <Amount value={totalBalance} semiBold isLoading={isLoading} {...props} />} | ||
|
||
{availableBalance !== totalBalance && availableBalance !== undefined && ( | ||
<AmountSubtitle> | ||
{`${t('Available')}: `} | ||
<Amount tokenId={props.tokenId} value={availableBalance} color={theme.font.tertiary} overrideSuffixColor /> | ||
</AmountSubtitle> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default FTAmounts | ||
|
||
const AmountSubtitle = styled.div` | ||
color: ${({ theme }) => theme.font.tertiary}; | ||
font-size: 10px; | ||
` |
27 changes: 27 additions & 0 deletions
27
apps/desktop-wallet/src/components/amounts/FTWorthAmount.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,27 @@ | ||
import { calculateAmountWorth } from '@alephium/shared' | ||
import { isNumber } from 'lodash' | ||
|
||
import { useFetchTokenPrice } from '@/api/apiDataHooks/market/useFetchTokenPrices' | ||
import Amount, { AmountLoaderProps, FiatAmountProps } from '@/components/Amount' | ||
|
||
type FTWorthAmountProps = Omit<FiatAmountProps, 'value' | 'isFiat'> & | ||
AmountLoaderProps & { | ||
symbol: string | ||
decimals: number | ||
totalBalance?: bigint | ||
} | ||
|
||
const FTWorthAmount = ({ symbol, totalBalance, decimals, ...props }: FTWorthAmountProps) => { | ||
const { data: tokenPrice } = useFetchTokenPrice(symbol) | ||
|
||
const worth = | ||
totalBalance !== undefined && isNumber(tokenPrice) | ||
? calculateAmountWorth(totalBalance, tokenPrice, decimals) | ||
: undefined | ||
|
||
if (worth === undefined) return '-' | ||
|
||
return <Amount value={worth} isFiat semiBold {...props} /> | ||
} | ||
|
||
export default FTWorthAmount |
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
Oops, something went wrong.