import { Modello, PrismaClient } from "@/generated/prisma";

export async function POST(request: Request) {
  const prisma = new PrismaClient();
  const data = await request.json();

  await prisma.registratore.create({
    data: {
      id: data.seriale,
      id_cliente: data.id,
      data_acquisto: new Date(data.data),
      modello:
        data.modello === "FORM100"
          ? Modello.FORM100
          : data.modello === "FORM200"
            ? Modello.FORM200
            : data.modello === "FORM200PLUS"
              ? Modello.FORM200PLUS
              : Modello.FORM500,
    },
  });

  return Response.json({ message: "fatto bastardo" });
}
