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 { breakpoints } from 'utils/theme' import { Badge, RewardsLeaderboardItem, fetchLeaderboard, tiers, } from './RewardsPage' 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' 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: rewardsLeaderboardData, isFetching: fetchingRewardsLeaderboardData, isLoading: loadingRewardsLeaderboardData, } = useQuery( ['rewards-leaderboard-data', topAccountsTier], () => fetchLeaderboard(topAccountsTier), { cacheTime: 1000 * 60 * 10, staleTime: 1000 * 60, retry: 3, refetchOnWindowFocus: false, }, ) const isLoading = fetchingRewardsLeaderboardData || loadingRewardsLeaderboardData return (

Leaderboard

{!isLoading ? ( rewardsLeaderboardData && rewardsLeaderboardData.length ? ( rewardsLeaderboardData.map( (wallet: RewardsLeaderboardItem, i: number) => ( ), ) ) : (
Leaderboard not available
) ) : (
{[...Array(20)].map((x, i) => (
))}
)}
) } export default Leaderboards const LeaderboardCard = ({ rank, wallet, }: { rank: number wallet: RewardsLeaderboardItem }) => { const { width } = useViewport() const isMobile = width ? width < breakpoints.md : false return (

{rank}

{rank < 4 ? : null}

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

{/*

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

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