import { useState, type ReactNode } from 'react'; import type { LeadeboardUserDetails, ListLeaderboardStatsResponse, } from '../../api/leaderboard'; import { cn } from '../../lib/classname'; import { FolderKanban, Zap, Trophy } from 'lucide-react'; import { RankBadgeIcon } from '../ReactIcons/RankBadgeIcon'; import { TrophyEmoji } from '../ReactIcons/TrophyEmoji'; import { SecondPlaceMedalEmoji } from '../ReactIcons/SecondPlaceMedalEmoji'; import { ThirdPlaceMedalEmoji } from '../ReactIcons/ThirdPlaceMedalEmoji'; type LeaderboardPageProps = { stats: ListLeaderboardStatsResponse; }; export function LeaderboardPage(props: LeaderboardPageProps) { const { stats } = props; return (

Leaderboard

Top users based on their activity on roadmap.sh

, emptyText: 'No users with streaks yet', }, ]} /> , emptyText: 'No projects submitted this month', }, { title: 'Lifetime', users: stats.projectSubmissions.lifetime, emptyIcon: , emptyText: 'No projects submitted yet', }, ]} />
); } type LeaderboardLaneProps = { title: string; tabs: { title: string; users: LeadeboardUserDetails[]; emptyIcon?: ReactNode; emptyText?: string; }[]; }; function LeaderboardLane(props: LeaderboardLaneProps) { const { title, tabs } = props; const [activeTab, setActiveTab] = useState(tabs[0]); const { users: usersToShow, emptyIcon, emptyText } = activeTab; return (

{title}

{tabs.length > 1 && (
{tabs.map((tab) => { const isActive = tab === activeTab; return ( ); })}
)}
{usersToShow.length === 0 && emptyText && (
{emptyIcon}

{emptyText}

)} {usersToShow.length > 0 && ( )}
); }