import React from 'react'; import { FiArrowRight, FiHash } from 'react-icons/fi'; import { cn } from '../../../lib/utils'; import { TransactionSection } from './CommonFields'; import { TransactionTransfer, TokenTransfer, AirdropData } from './types'; import { formatTokenAmount } from '../../../hooks/useTokenInfo'; interface HbarTransfersSectionProps { transfers: TransactionTransfer[]; } export const HbarTransfersSection: React.FC = ({ transfers, }) => ( {transfers.map((transfer, idx) => (
{transfer.accountId} = 0 ? 'text-white bg-white/10' : 'text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20' )} > {transfer.amount >= 0 ? '+' : ''} {transfer.amount} ℏ
))}
); interface TokenTransfersSectionProps { tokenTransfers: TokenTransfer[]; tokenInfoMap: Map; } export const TokenTransfersSection: React.FC = ({ tokenTransfers, tokenInfoMap, }) => ( {tokenTransfers.map((transfer, idx) => { const tokenInfo = tokenInfoMap.get(transfer.tokenId); const formattedAmount = tokenInfo && !tokenInfo.loading ? formatTokenAmount(transfer.amount, tokenInfo.decimals) : transfer.amount.toString(); const symbol = tokenInfo?.symbol || ''; return (
{transfer.tokenId} {symbol ? ({symbol}) : null} {transfer.accountId}
= 0 ? 'text-white bg-white/10' : 'text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20' )} > {transfer.amount >= 0 ? '+' : ''} {formattedAmount} {symbol}
); })}
); interface AirdropSectionProps { airdropData: AirdropData; tokenInfoMap: Map; } export const AirdropSection: React.FC = ({ airdropData, tokenInfoMap, }) => ( {airdropData.tokenTransfers?.map((tokenTransfer, idx) => { const tokenInfo = tokenInfoMap.get(tokenTransfer.tokenId); const symbol = tokenInfo?.symbol || ''; const tokenName = tokenInfo?.name || ''; return (
Token: {tokenTransfer.tokenId} {(tokenName || symbol) && ( ({tokenName} {tokenName && symbol ? ' - ' : ''} {symbol}) )}
{tokenTransfer.transfers.map((transfer, transferIdx) => { const formattedAmount = tokenInfo && !tokenInfo.loading ? formatTokenAmount(transfer.amount, tokenInfo.decimals) : transfer.amount; return (
{transfer.accountId} +{formattedAmount} {symbol || 'tokens'}
); })}
); })}
);