"use client"; import Link from "next/link"; import { History, ReceiptText, Settings, Trophy, ChevronRight, Sparkles, Zap } from "lucide-react"; import type { PublicUser } from "@spinza/shared"; import { formatMultiplier, formatSC } from "@spinza/shared"; import { useSession } from "@/lib/store"; import { useApi } from "@/lib/use-api"; import { Card, Credits, Progress, Skeleton } from "@/components/ui"; import { AppShell } from "@/components/shell/app-shell"; import { RequireAuth } from "@/components/shell/require-auth"; import { ApiErrorState } from "@/components/shell/api-error"; import { GameArt, type ArtPalette } from "@/components/lobby/game-art"; interface Profile { user: PublicUser; wallet: { balance: number; lifetimeWagered: number; lifetimeWon: number }; stats: { totalSpins: number; gamesPlayed: number; biggestWin: number; biggestMultiplier: number; bonuses: number; achievements: number }; favoriteGame: { slug: string; name: string; spins: number; palette: ArtPalette } | null; } function Stat({ label, value, sub }: { label: string; value: React.ReactNode; sub?: string }) { return (
{label}
{value}
{sub ?
{sub}
: null}
); } const LINKS = [ { href: "/profile/history", label: "Round history", desc: "Every spin, with full results", icon: History }, { href: "/profile/ledger", label: "Credit ledger", desc: "All credit movements", icon: ReceiptText }, { href: "/rewards", label: "Achievements", desc: "Milestones and rewards", icon: Trophy }, { href: "/settings", label: "Settings", desc: "Sound, motion, security", icon: Settings }, ]; function ProfileBody() { const { data, error, loading, reload } = useApi("/api/user/profile"); const wallet = useSession((s) => s.wallet); if (error && !data) return ; if (loading && !data) { return (
{Array.from({ length: 8 }).map((_, i) => ( ))}
); } if (!data) return null; const { user, stats, favoriteGame } = data; const balance = wallet?.balance ?? data.wallet.balance; const joined = new Date(user.createdAt).toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric" }); return (
{/* identity */}
{user.username.slice(0, 1)}

{user.username}

LVL {user.level}

Member since {joined}

{user.xpIntoLevel.toLocaleString("en-US")} XP {user.xpForNext ? `${user.xpForNext.toLocaleString("en-US")} XP to level ${user.level + 1}` : "Max level"}
Balance
{/* stats */}

Lifetime stats

{formatSC(stats.biggestWin)}} />
{/* favourite game */}

Most played

{favoriteGame ? (
{favoriteGame.spins.toLocaleString("en-US")} spins Play again
) : (
No favourite yet

Play a few rounds and your most-played game appears here.{" "} Browse games

)}
{/* shortcuts */}

Account

{LINKS.map((l) => (
  • {l.label} {l.desc}
  • ))}
    ); } export default function ProfilePage() { return ( ); }