diff --git a/front/src/routes/grupos/[id]/+page.ts b/front/src/routes/grupos/[id]/+page.ts index c934f1b..87528b1 100644 --- a/front/src/routes/grupos/[id]/+page.ts +++ b/front/src/routes/grupos/[id]/+page.ts @@ -1,20 +1,16 @@ import { redirect } from '@sveltejs/kit'; -import { obtenerGrupos } from '$lib/api'; +import { obtenerGrupo } from '$lib/api'; import type { Grupo } from '../../../types'; import type { PageLoad } from './$types'; -export const load: PageLoad = async ({ params }) => { +export const load: PageLoad = async ({ params, fetch }) => { const id = Number(params.id); - let grupos: Grupo[]; + let grupo: Grupo; try { - grupos = await obtenerGrupos(); + grupo = await obtenerGrupo(id, fetch); } catch { - throw redirect(302, '/'); - } - const grupo = grupos.find((g) => g.id === id) ?? null; - if (!grupo) { - throw redirect(302, '/grupos'); + throw redirect(302, '/menu'); } return { grupo };