import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Switch } from "@/components/ui/switch"; export default function BannerSettings() { const [text, setText] = useState("ROBLOX AUTH SOON"); const [enabled, setEnabled] = useState(true); const [saving, setSaving] = useState(false); const [style, setStyle] = useState("quest"); useEffect(() => { fetch("/api/site-settings?key=home_banner") .then((r) => (r.ok ? r.json() : null)) .then((v) => { if (v && typeof v === "object") { setText(String((v as any).text || "ROBLOX AUTH SOON")); setEnabled((v as any).enabled !== false); if ((v as any).style) setStyle(String((v as any).style)); } }) .catch(() => void 0); }, []); const save = async () => { setSaving(true); try { const resp = await fetch("/api/site-settings", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ key: "home_banner", value: { text, enabled, style }, }), }); if (!resp.ok) throw new Error("Save failed"); } finally { setSaving(false); } }; return (
setText(e.target.value)} placeholder="Banner message" />
); }