"use client"; import { useState, useEffect } from "react"; import { Settings, Save, RotateCcw, KeyRound, Trash2, Loader2, } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { Badge } from "@/components/ui/badge"; import { toast } from "sonner"; import { useAuth } from "@/components/auth/auth-provider"; interface AppSettings { characterRefreshInterval: number; automationRefreshInterval: number; mapAutoRefresh: boolean; } const DEFAULT_SETTINGS: AppSettings = { characterRefreshInterval: 5, automationRefreshInterval: 3, mapAutoRefresh: true, }; function loadSettings(): AppSettings { if (typeof window === "undefined") return DEFAULT_SETTINGS; try { const saved = localStorage.getItem("artifacts-settings"); if (saved) return { ...DEFAULT_SETTINGS, ...JSON.parse(saved) }; } catch {} return DEFAULT_SETTINGS; } export default function SettingsPage() { const [settings, setSettings] = useState(DEFAULT_SETTINGS); const { status: authStatus, setToken, removeToken } = useAuth(); const [newToken, setNewToken] = useState(""); const [tokenLoading, setTokenLoading] = useState(false); useEffect(() => { setSettings(loadSettings()); }, []); function handleSave() { try { localStorage.setItem("artifacts-settings", JSON.stringify(settings)); toast.success("Settings saved"); } catch { toast.error("Failed to save settings"); } } function handleReset() { setSettings(DEFAULT_SETTINGS); localStorage.removeItem("artifacts-settings"); toast.success("Settings reset to defaults"); } async function handleSetToken(e: React.FormEvent) { e.preventDefault(); if (!newToken.trim()) return; setTokenLoading(true); const result = await setToken(newToken.trim()); setTokenLoading(false); if (result.success) { setNewToken(""); toast.success("API token updated"); } else { toast.error(result.error || "Failed to set token"); } } async function handleRemoveToken() { setTokenLoading(true); await removeToken(); setTokenLoading(false); toast.success("API token removed"); } return (

Settings

Configure dashboard preferences

API Token
Status: {authStatus?.has_token ? ( Connected ( {authStatus.source === "env" ? "environment" : "user-provided"} ) ) : ( Not configured )}
{authStatus?.source !== "env" && (
setNewToken(e.target.value)} placeholder="Paste your Artifacts MMO token..." disabled={tokenLoading} />
{authStatus?.has_token && authStatus.source === "user" && ( )}
)} {authStatus?.source === "env" && (

Token is configured via environment variable. To change it, update the ARTIFACTS_TOKEN in your .env file and restart the backend.

)}
Refresh Intervals
setSettings((s) => ({ ...s, characterRefreshInterval: parseInt(e.target.value, 10) || 5, })) } />
setSettings((s) => ({ ...s, automationRefreshInterval: parseInt(e.target.value, 10) || 3, })) } />
); }