/* 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 } = useAccountHistory()
return (
{history?.length ? (
history.map((history: ActivityFeed | any) => {
const { activity_type, activity_details } = history
return (
)
})
) : isLoading ? (
[...Array(4)].map((x, i) => (
))
) : (
No transaction history 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}`}
)
}