import { NextResponse } from "next/server";
import { requireAdminSession } from "@/lib/admin/auth";
import { saveSiteSettings } from "@/lib/admin/store";

export async function POST(request: Request) {
  if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
  await saveSiteSettings(await request.formData());
  return new NextResponse(null, { status: 303, headers: { Location: "/admin/einstellungen?saved=1" } });
}
