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 status = body?.status as "active" | "suspended" | "withdrawn" | undefined;
  if (!status) return NextResponse.json({ error: "invalid status" }, { status: 400 });
  const user = await prisma.user.update({ where: { userId: id }, data: { status } });
  return NextResponse.json({ user });
}


