4cf35f9280
Páginas cliente: login magic link, registro, validación de token, dashboard de autos, historial por auto y reserva de turnos con selector de servicio + slots disponibles. Páginas admin: login, dashboard de turnos del día con cambio de estado, historial de autos (buscar cliente → auto → ver/cargar registros), gestión de tipos de servicio y vista de clientes. Middleware JWT para proteger rutas /cliente/* y /admin/*. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1004 B
TypeScript
34 lines
1004 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { verificarSesion } from "@/lib/auth-admin";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const sesion = await verificarSesion("admin_session");
|
|
if (!sesion) return NextResponse.json({ error: "No autorizado" }, { status: 401 });
|
|
|
|
const { searchParams } = new URL(req.url);
|
|
const fecha = searchParams.get("fecha"); // YYYY-MM-DD
|
|
const clienteId = searchParams.get("clienteId");
|
|
|
|
const where: Record<string, unknown> = {};
|
|
if (fecha) {
|
|
where.fechaInicio = {
|
|
gte: new Date(`${fecha}T00:00:00`),
|
|
lte: new Date(`${fecha}T23:59:59`),
|
|
};
|
|
}
|
|
if (clienteId) where.clienteId = clienteId;
|
|
|
|
const turnos = await prisma.turno.findMany({
|
|
where,
|
|
include: {
|
|
cliente: { select: { nombre: true, apellido: true, telefono: true } },
|
|
auto: true,
|
|
tipoServicio: true,
|
|
},
|
|
orderBy: { fechaInicio: "asc" },
|
|
});
|
|
|
|
return NextResponse.json(turnos);
|
|
}
|