"use client"; import { useState } from "react"; import Link from "next/link"; import { Crown, Trophy, EyeOff, Info } from "lucide-react"; import type { LeaderboardView, LeaderboardEntry } from "@spinza/shared"; import { formatMultiplier, formatSC } from "@spinza/shared"; import { useSession } from "@/lib/store"; import { useApi } from "@/lib/use-api"; import { cn, timeAgo } from "@/lib/utils"; import { Card, Empty, Skeleton, Tabs } from "@/components/ui"; import { AppShell } from "@/components/shell/app-shell"; import { ApiErrorState } from "@/components/shell/api-error"; const CATEGORIES = [ { value: "biggest_win_today", label: "Biggest Win Today", short: "Today" }, { value: "biggest_win_week", label: "Biggest Win This Week", short: "This Week" }, { value: "biggest_multiplier", label: "Biggest Multiplier", short: "Multiplier" }, { value: "most_spins", label: "Most Spins", short: "Spins" }, { value: "highest_level", label: "Highest Level", short: "Level" }, ] as const; type Category = (typeof CATEGORIES)[number]["value"]; function formatValue(cat: Category, v: number): string { switch (cat) { case "biggest_multiplier": return formatMultiplier(v); case "most_spins": return `${Math.round(v).toLocaleString("en-US")} spins`; case "highest_level": return `Level ${Math.round(v)}`; default: return formatSC(v); } } function Avatar({ name, rank, size = "md" }: { name: string; rank: number; size?: "md" | "lg" }) { const ring = rank === 1 ? "ring-2 ring-accent shadow-glow" : rank === 2 ? "ring-2 ring-[#c7ccd8]" : rank === 3 ? "ring-2 ring-[#b87b4b]" : "ring-1 ring-line-2"; return ( {name.slice(0, 1)} ); } function Podium({ entries, cat }: { entries: LeaderboardEntry[]; cat: Category }) { const order = [entries[1], entries[0], entries[2]].filter(Boolean) as LeaderboardEntry[]; if (!entries.length) return null; return (
Bragging rights only. All values are in fictional Spinza Credits or gameplay stats — nothing is ever paid out.
You have opted out of leaderboards, so your results are hidden from other players.{" "} Change in settings
{optIn ? "You are not on this board yet. Play a few rounds to enter." : "Opt back in to appear on leaderboards."}
) : null ) : (Sign in {" "} to see where you rank.
)} {data?.updatedAt ?Updated {timeAgo(data.updatedAt)}
: null}Privacy: leaderboards show your username, level and result only. You can leave all leaderboards at any time from{" "} Settings → Leaderboard participation . Spinza never shares data with third parties.