mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Convert settings page to server component with server actions
Replace client-side data fetching with server-side queries and server actions, eliminating 3 API route files. Extract page into granular client components (account, integrations, server, webhook card) with optimistic updates. Rename sections: Media Servers → Integrations, Administration → Server. Add admin badge to account section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
import { headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/lib/auth/server";
|
||||
import { getSetting, setSetting } from "@/lib/services/settings";
|
||||
|
||||
export async function GET() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session)
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
if (session.user.role !== "admin")
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
|
||||
const registrationOpen = (await getSetting("registrationOpen")) === "true";
|
||||
return NextResponse.json({ registrationOpen });
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session)
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
if (session.user.role !== "admin")
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
|
||||
const body = await request.json();
|
||||
if (typeof body.registrationOpen === "boolean") {
|
||||
await setSetting("registrationOpen", String(body.registrationOpen));
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
Reference in New Issue
Block a user