fix: correjida llamada para obtener el grupo

This commit is contained in:
fede committed 2026-06-14 02:24:37 -03:00
1 parent b2278811d8
commit 8464a0fd1d
1 file changed
+5 -9
+5 -9
View File
@@ -1,20 +1,16 @@
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import { obtenerGrupos } from '$lib/api'; import { obtenerGrupo } from '$lib/api';
import type { Grupo } from '../../../types'; import type { Grupo } from '../../../types';
import type { PageLoad } 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); const id = Number(params.id);
let grupos: Grupo[]; let grupo: Grupo;
try { try {
grupos = await obtenerGrupos(); grupo = await obtenerGrupo(id, fetch);
} catch { } catch {
throw redirect(302, '/'); throw redirect(302, '/menu');
}
const grupo = grupos.find((g) => g.id === id) ?? null;
if (!grupo) {
throw redirect(302, '/grupos');
} }
return { grupo }; return { grupo };