From b6705239a1f5bc649321a982bf492c5159e7d08c Mon Sep 17 00:00:00 2001 From: Beldor Date: Sat, 20 Jun 2026 23:20:25 -0300 Subject: [PATCH] fix(cliente): cargar servicios desde endpoint de cliente en vez de admin Co-Authored-By: Claude Sonnet 4.6 --- src/app/api/cliente/servicios/route.ts | 15 +++++++++++++++ src/app/cliente/turnos/page.tsx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/app/api/cliente/servicios/route.ts diff --git a/src/app/api/cliente/servicios/route.ts b/src/app/api/cliente/servicios/route.ts new file mode 100644 index 0000000..0f13d0d --- /dev/null +++ b/src/app/api/cliente/servicios/route.ts @@ -0,0 +1,15 @@ +import { NextResponse } from "next/server"; +import { prisma } from "@/lib/prisma"; +import { verificarSesion } from "@/lib/auth-admin"; + +export async function GET() { + const sesion = await verificarSesion("cliente_session"); + if (!sesion) return NextResponse.json({ error: "No autorizado" }, { status: 401 }); + + const servicios = await prisma.tipoServicio.findMany({ + where: { activo: true }, + orderBy: { nombre: "asc" }, + }); + + return NextResponse.json(servicios); +} diff --git a/src/app/cliente/turnos/page.tsx b/src/app/cliente/turnos/page.tsx index aef72b7..7180747 100644 --- a/src/app/cliente/turnos/page.tsx +++ b/src/app/cliente/turnos/page.tsx @@ -37,9 +37,9 @@ function TurnosContent() { useEffect(() => { if (!autoId) { router.push("/cliente/dashboard"); return; } - fetch("/api/admin/servicios") + fetch("/api/cliente/servicios") .then((r) => r.json()) - .then((data) => setServicios(data.filter((s: TipoServicio & { activo: boolean }) => s.activo))); + .then((data) => setServicios(data)); fetch("/api/cliente/turnos") .then((r) => r.json()) .then((data) => { setMisTurnos(data.filter((t: Turno & { autoId: string }) => t.autoId === autoId)); setLoadingTurnos(false); });