import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";

export async function PATCH(req: Request, context: { params: Promise<{ id: string }> }) {
  const { id } = await context.params;
  const body = await req.json().catch(() => ({}));
  const data: any = {};
  for (const k of ["name", "slug", "sortOrder", "status"]) {
    if (k in body) data[k] = body[k];
  }
  const category = await prisma.boardCategory.update({ where: { id }, data });
  return NextResponse.json({ category });
}

export async function DELETE(req: Request, context: { params: Promise<{ id: string }> }) {
  const { id } = await context.params;
  await prisma.boardCategory.delete({ where: { id } });
  return NextResponse.json({ ok: true });
}


