import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { getApiUser } from "@/lib/apiAuth";
export async function PUT(req: NextRequest) {
  const apiUser = await getApiUser(req);
  if (!apiUser) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });

  const { name } = await req.json();
  const user = await db.user.update({
    where: { id: apiUser.id },
    data: { name },
  });
  return NextResponse.json({ name: user.name });
}
