import MedalIcon from '@components/icons/MedalIcon' import ProfileImage from '@components/profile/ProfileImage' import { ArrowLeftIcon, ChevronRightIcon } from '@heroicons/react/20/solid' import { useViewport } from 'hooks/useViewport' import { useState } from 'react' import Select from '@components/forms/Select' import { IconButton } from '@components/shared/Button' import AcornIcon from '@components/icons/AcornIcon' import WhaleIcon from '@components/icons/WhaleIcon' import RobotIcon from '@components/icons/RobotIcon' import MangoIcon from '@components/icons/MangoIcon' import { useQuery } from '@tanstack/react-query' import SheenLoader from '@components/shared/SheenLoader' import { abbreviateAddress } from 'utils/formatting' import { PublicKey } from '@solana/web3.js' import { formatNumericValue } from 'utils/numbers' import { useTranslation } from 'next-i18next' import { fetchLeaderboard } from 'apis/rewards' import { useCurrentSeason } from 'hooks/useRewards' import Badge from './Badge' import { tiers } from './RewardsPage' const Leaderboards = ({ goBack, leaderboard, }: { goBack: () => void leaderboard: string }) => { const { t } = useTranslation('rewards') const [topAccountsTier, setTopAccountsTier] = useState(leaderboard) const renderTierIcon = (tier: string) => { if (tier === 'bot') { return } else if (tier === 'mango') { return } else if (tier === 'whale') { return } else return } const { data: seasonData } = useCurrentSeason() const { data: topAccountsLeaderboardData, isFetching: fetchingRewardsLeaderboardData, isLoading: loadingRewardsLeaderboardData, } = useQuery( ['rewards-leaderboard-data', topAccountsTier], () => fetchLeaderboard(seasonData!.season_id), { cacheTime: 1000 * 60 * 10, staleTime: 1000 * 60, retry: 3, refetchOnWindowFocus: false, enabled: !!seasonData, }, ) const leadersForTier = topAccountsLeaderboardData?.find((x) => x.tier === topAccountsTier) ?.leaderboard || [] const isLoading = fetchingRewardsLeaderboardData || loadingRewardsLeaderboardData return (

Leaderboard

{!isLoading ? ( leadersForTier && leadersForTier.length ? ( leadersForTier.map((wallet, i: number) => ( )) ) : (
Leaderboard not available
) ) : (
{[...Array(20)].map((x, i) => (
))}
)}
) } export default Leaderboards const LeaderboardCard = ({ rank, wallet, }: { rank: number wallet: { mango_account: string tier: string total_points: number } }) => { const { isTablet } = useViewport() return (

{rank}

{rank < 4 ? : null}

{abbreviateAddress(new PublicKey(wallet.mango_account))}

{/*

Acc: {'A1at5'.slice(0, 4) + '...' + 'tt45eU'.slice(-4)}

*/}
{formatNumericValue(wallet.total_points)}
) }