/* eslint-disable react/no-array-index-key */ import type { LiFiStep, TokenAmount } from '@lifi/sdk'; import type { BoxProps } from '@mui/material'; import { Box, Grow, Skeleton } from '@mui/material'; import type { FC, PropsWithChildren, ReactElement } from 'react'; import { useTranslation } from 'react-i18next'; import { useChain, useToken } from '../../hooks'; import { formatTokenAmount, formatTokenPrice } from '../../utils'; import { SmallAvatar } from '../SmallAvatar'; import { TextFitter } from '../TextFitter'; import { TokenAvatar, TokenAvatarSkeleton } from '../TokenAvatar'; import { TextSecondary, TextSecondaryContainer } from './Token.style'; interface TokenProps { token: TokenAmount; step?: LiFiStep; stepVisible?: boolean; disableDescription?: boolean; isLoading?: boolean; } export const Token: FC = ({ token, ...other }) => { if (!token.priceUSD || !token.logoURI) { return ; } return ; }; export const TokenFallback: FC = ({ token, isLoading, ...other }) => { const { token: chainToken, isLoading: isLoadingToken } = useToken( token.chainId, token.address, ); return ( ); }; export const TokenBase: FC = ({ token, step, stepVisible, disableDescription, isLoading, ...other }) => { const { t } = useTranslation(); const { chain } = useChain(token?.chainId); if (isLoading) { return ( ); } const formattedTokenAmount = formatTokenAmount(token.amount, token.decimals); const formattedTokenPrice = formatTokenPrice( formattedTokenAmount, token.priceUSD, ); const tokenOnChain = !disableDescription ? ( {t(`main.tokenOnChain`, { tokenSymbol: token.symbol, chainName: chain?.name, })} ) : null; return ( {t('format.number', { value: formattedTokenAmount, })} {t(`format.currency`, { value: formattedTokenPrice, })} {!disableDescription ? ( ) : null} {step ? ( {tokenOnChain} ) : ( tokenOnChain )} ); }; const TokenStep: FC>> = ({ step, stepVisible, disableDescription, children, }) => { return ( {children as ReactElement} {step?.toolDetails.name[0]} {step?.toolDetails.name} ); }; export const TokenSkeleton: FC & BoxProps> = ({ step, disableDescription, ...other }) => { return ( {!step && !disableDescription ? ( ) : null} ); };