Private
Public Access
fix: correjida llamada para obtener el grupo
This commit is contained in:
1 parent
b2278811d8
commit
8464a0fd1d
1 file changed
+5
-9
@@ -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 };
|
||||
|
||||
Reference in new issue
Block a user