/* eslint-disable @typescript-eslint/no-explicit-any */ import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid' import dayjs from 'dayjs' import useAccountHistory from 'hooks/useAccountHistory' import { ActivityFeed, DepositWithdrawFeedItem, SwapHistoryItem } from 'types' import SheenLoader from './shared/SheenLoader' const TransactionHistory = () => { const { history, isLoading, refetch } = useAccountHistory() return (
History may be delayed by a few minutes. {' '}
{history?.length ? ( history.map((history: ActivityFeed | any) => { const { activity_type, activity_details } = history const symbol = activity_details.symbol || '' return ( ) }) ) : isLoading ? ( [...Array(4)].map((x, i) => (
)) ) : (
😑 No activity found...
)}
) } export default TransactionHistory type HistoryContentProps = { details: SwapHistoryItem | DepositWithdrawFeedItem type: string } function isDeposit( details: SwapHistoryItem | DepositWithdrawFeedItem, ): details is DepositWithdrawFeedItem { if ('quantity' in details) return true else return false } function isSwap( details: SwapHistoryItem | DepositWithdrawFeedItem, ): details is SwapHistoryItem { if ('swap_in_amount' in details) return true else return false } const HistoryContent = ({ details, type }: HistoryContentProps) => { switch (type) { case 'deposit': if (isDeposit(details)) { return } break case 'swap': if (isSwap(details)) { return } break default: return null } return null } const DepositHistory = ({ details }: { details: DepositWithdrawFeedItem }) => { const { block_datetime, quantity, signature, symbol } = details return (

{dayjs(block_datetime).format('ddd D MMM h:mma')}

{`Deposit ${quantity} ${symbol}`}

) } const SwapHistory = ({ details }: { details: SwapHistoryItem }) => { const { block_datetime, signature, swap_in_amount, swap_in_symbol, swap_out_amount, swap_out_symbol, } = details return (

{dayjs(block_datetime).format('ddd D MMM h:mma')}

{`Swap ${swap_in_amount} ${swap_in_symbol} for ${swap_out_amount} ${swap_out_symbol}`}

) }