import { useCallback, useEffect, useState } from "react"; import { Loader2, AlertTriangle, Save, Check, TrendingUp, Coins, Package, Gift, Brain, Shield, Terminal, RotateCcw, Server, X, } from "lucide-react"; import { cn } from "../lib/utils"; import { useSettings, type GameSettings, type GuildSettings, type SettingsMeta, } from "../lib/useSettings"; // --------------------------------------------------------------------------- // Helpers // --------------------------------------------------------------------------- type SettingsSection = | "guild" | "leveling" | "economy" | "inventory" | "lootdrop" | "trivia" | "moderation" | "commands"; const sections: { key: SettingsSection; label: string; icon: React.ComponentType<{ className?: string }>; }[] = [ { key: "guild", label: "Guild", icon: Server }, { key: "leveling", label: "Leveling", icon: TrendingUp }, { key: "economy", label: "Economy", icon: Coins }, { key: "inventory", label: "Inventory", icon: Package }, { key: "lootdrop", label: "Lootdrops", icon: Gift }, { key: "trivia", label: "Trivia", icon: Brain }, { key: "moderation", label: "Moderation", icon: Shield }, { key: "commands", label: "Commands", icon: Terminal }, ]; function formatMs(ms: number): string { if (ms >= 86_400_000) return `${ms / 86_400_000}h`; if (ms >= 60_000) return `${ms / 60_000} min`; return `${ms / 1_000}s`; } // --------------------------------------------------------------------------- // Reusable field components // --------------------------------------------------------------------------- function Field({ label, hint, children, }: { label: string; hint?: string; children: React.ReactNode; }) { return (
{hint}
}