"use client"; import { useState } from "react"; import { toast } from "sonner"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; export function SignupsToggle({ initialDisabled }: { initialDisabled: boolean }) { const [enabled, setEnabled] = useState(!initialDisabled); const [saving, setSaving] = useState(false); async function handleChange(checked: boolean) { setSaving(true); const previous = enabled; setEnabled(checked); try { const res = await fetch("/api/v1/admin/settings", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ SIGNUPS_DISABLED: checked ? null : "true" }), }); if (!res.ok) throw new Error("Save failed"); toast.success(checked ? "Signups enabled" : "Signups disabled"); } catch { setEnabled(previous); toast.error("Failed to update"); } finally { setSaving(false); } } return (

Signups

When off, only people with a valid invite link can create an account.

{ void handleChange(checked); }} />
); }