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 ["region", "name", "address", "imageUrl", "active", "sortOrder"]) {
    if (k in body) data[k] = body[k];
  }
  const item = await prisma.partnerShop.update({ where: { id }, data });
  return NextResponse.json({ item });
}

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


