93ad1cb8c1
Estructura inicial con Next.js 14, PostgreSQL/Prisma 7, autenticación por magic link (clientes) y JWT (admins), lógica de scheduling con 4 slots paralelos y API routes completas para cliente y panel admin. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
759 B
TypeScript
19 lines
759 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const { email, nombre, apellido, telefono } = await req.json();
|
|
|
|
if (!email || !nombre || !apellido || !telefono)
|
|
return NextResponse.json({ error: "Todos los campos son requeridos" }, { status: 400 });
|
|
|
|
const existe = await prisma.cliente.findUnique({ where: { email: email.toLowerCase() } });
|
|
if (existe) return NextResponse.json({ error: "El email ya está registrado" }, { status: 409 });
|
|
|
|
const cliente = await prisma.cliente.create({
|
|
data: { email: email.toLowerCase().trim(), nombre, apellido, telefono },
|
|
});
|
|
|
|
return NextResponse.json({ ok: true, id: cliente.id }, { status: 201 });
|
|
}
|