feat: admin panel improvements (v0.34.0)
- Signups toggle was inverted (on = disabled) — flipped so on means open, matching how every other on/off toggle in the app reads. - Moved AI provider keys and default-model settings from Site Settings to AI Config, so all AI setup lives in one place instead of split across two pages with a cross-link. - Admin overview: added new users/recipes (7d), recipes cooked (7d), pending reports (linked, highlighted if > 0), storage used this month, active webhooks, and API keys issued — previously just 4 lifetime totals. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,23 +6,23 @@ import { Label } from "@/components/ui/label";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
|
||||
export function SignupsToggle({ initialDisabled }: { initialDisabled: boolean }) {
|
||||
const [disabled, setDisabled] = useState(initialDisabled);
|
||||
const [enabled, setEnabled] = useState(!initialDisabled);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
async function handleChange(checked: boolean) {
|
||||
setSaving(true);
|
||||
const previous = disabled;
|
||||
setDisabled(checked);
|
||||
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 ? "true" : null }),
|
||||
body: JSON.stringify({ SIGNUPS_DISABLED: checked ? null : "true" }),
|
||||
});
|
||||
if (!res.ok) throw new Error("Save failed");
|
||||
toast.success(checked ? "Signups disabled" : "Signups enabled");
|
||||
toast.success(checked ? "Signups enabled" : "Signups disabled");
|
||||
} catch {
|
||||
setDisabled(previous);
|
||||
setEnabled(previous);
|
||||
toast.error("Failed to update");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
@@ -35,16 +35,16 @@ export function SignupsToggle({ initialDisabled }: { initialDisabled: boolean })
|
||||
<div>
|
||||
<h2 className="font-semibold text-lg">Signups</h2>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
When disabled, only people with a valid invite link can create an account.
|
||||
When off, only people with a valid invite link can create an account.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Label htmlFor="signups-disabled" className="text-sm">
|
||||
{disabled ? "Disabled" : "Open"}
|
||||
<Label htmlFor="signups-enabled" className="text-sm">
|
||||
{enabled ? "Open" : "Disabled"}
|
||||
</Label>
|
||||
<Switch
|
||||
id="signups-disabled"
|
||||
checked={disabled}
|
||||
id="signups-enabled"
|
||||
checked={enabled}
|
||||
disabled={saving}
|
||||
onCheckedChange={(checked) => { void handleChange(checked); }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user