fix(cliente): cargar servicios desde endpoint de cliente en vez de admin
Deploy / deploy (push) Failing after 33h14m30s
Deploy / deploy (push) Failing after 33h14m30s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
@@ -37,9 +37,9 @@ function TurnosContent() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!autoId) { router.push("/cliente/dashboard"); return; }
|
if (!autoId) { router.push("/cliente/dashboard"); return; }
|
||||||
fetch("/api/admin/servicios")
|
fetch("/api/cliente/servicios")
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((data) => setServicios(data.filter((s: TipoServicio & { activo: boolean }) => s.activo)));
|
.then((data) => setServicios(data));
|
||||||
fetch("/api/cliente/turnos")
|
fetch("/api/cliente/turnos")
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((data) => { setMisTurnos(data.filter((t: Turno & { autoId: string }) => t.autoId === autoId)); setLoadingTurnos(false); });
|
.then((data) => { setMisTurnos(data.filter((t: Turno & { autoId: string }) => t.autoId === autoId)); setLoadingTurnos(false); });
|
||||||
|
|||||||
Reference in New Issue
Block a user