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 ['key', 'name', 'scope']) { if (k in body) data[k] = body[k]; }
  const updated = await prisma.boardViewType.update({ where: { id }, data });
  return NextResponse.json({ item: updated });
}

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


