mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-05-03 18:12:46 -03:00
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { obtenerUsuarioPorUsername } from '@/hooks/obtenerUsuario.js';
|
|
import type { UserResponseDto } from '../../types.js';
|
|
import { error } from '@sveltejs/kit';
|
|
import type { PageLoad } from './$types';
|
|
import { obtenerSeguidosPorUsuario } from '@/hooks/obtenerSeguidosPorUsuario.js';
|
|
import { obtenerSeguidoresPorUsuario } from '@/hooks/obtenerSeguidoresPorUsuario.js';
|
|
import { obtenerCantidadDeSeguidores } from '@/hooks/obtenerCantidadDeSeguidores.js';
|
|
import { obtenerCantidadDeSeguidos } from '@/hooks/obtenerCantidadDeSeguidos.js';
|
|
|
|
export const load: PageLoad = async ({ params, depends, fetch }) => {
|
|
depends('perfil:general');
|
|
const usuario: UserResponseDto | null = await obtenerUsuarioPorUsername(params.perfil, fetch);
|
|
if (!usuario) error(404, 'No se encontro el usuario, ' + params.perfil);
|
|
|
|
const [seguidos, seguidores, countSeguidores, countSeguidos] = await Promise.all([
|
|
obtenerSeguidosPorUsuario(usuario.id, 1, 5, fetch),
|
|
obtenerSeguidoresPorUsuario(usuario.id, 1, 5, fetch),
|
|
obtenerCantidadDeSeguidores(usuario.id, fetch),
|
|
obtenerCantidadDeSeguidos(usuario.id, fetch)
|
|
]);
|
|
|
|
return {
|
|
...usuario,
|
|
seguidos,
|
|
seguidores,
|
|
countSeguidores: countSeguidores.count,
|
|
countSeguidos: countSeguidos.count
|
|
};
|
|
};
|