'use client' import { LEADERBOARD_PERIODS } from '~/data/contribute' import { ArrowLeft } from 'lucide-react' import Link from 'next/link' import { parseAsString, useQueryState } from 'nuqs' import { use } from 'react' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from 'ui' import { LeaderboardContent } from './LeaderboardContent' export function LeaderboardClient({ initialLeaderboardPromise, initialPeriod, }: { initialLeaderboardPromise: Promise initialPeriod: (typeof LEADERBOARD_PERIODS)[number] }) { const [period, setPeriod] = useQueryState( 'period', parseAsString.withDefault('all').withOptions({ shallow: false, }) ) const validPeriod = LEADERBOARD_PERIODS.includes(period as (typeof LEADERBOARD_PERIODS)[number]) ? (period as (typeof LEADERBOARD_PERIODS)[number]) : 'all' const periodLabels: Record<(typeof LEADERBOARD_PERIODS)[number], string> = { all: 'All time', year: 'This year', quarter: 'This quarter', month: 'This month', week: 'This week', today: 'Today', } // Use the initial promise if period hasn't changed, otherwise it will refetch via navigation const leaderboard = use(initialLeaderboardPromise) return (
{/* Back Link */} Back to Contribute {/* Header */}

Top Community Contributors

How does this work?
{/* Period Selector */}
{/* Leaderboard Content */}
) }