diff --git a/src/lib/hooks/obtenerSeguidoresPorUsuario.ts b/src/lib/hooks/obtenerSeguidoresPorUsuario.ts index 641aef3..0a57e4c 100644 --- a/src/lib/hooks/obtenerSeguidoresPorUsuario.ts +++ b/src/lib/hooks/obtenerSeguidoresPorUsuario.ts @@ -3,9 +3,9 @@ import type { UserResponseDto } from "../../types"; import { get } from "svelte/store"; import { apiBase } from "@/stores/url"; -export async function obtenerSeguidoresPorUsuario(Id: string): Promise { +export async function obtenerSeguidoresPorUsuario(id: string, limit:number = 20): Promise { try { - const response = await fetch(`${get(apiBase)}/api/users/${Id}/followers`, { + const response = await fetch(`${get(apiBase)}/api/users/${id}/followers?limit=${limit}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/lib/hooks/obtenerSeguidosPorUsuario.ts b/src/lib/hooks/obtenerSeguidosPorUsuario.ts index 2c1340a..a32aebe 100644 --- a/src/lib/hooks/obtenerSeguidosPorUsuario.ts +++ b/src/lib/hooks/obtenerSeguidosPorUsuario.ts @@ -3,9 +3,9 @@ import type { UserResponseDto } from "../../types"; import { apiBase } from "@/stores/url"; import { get } from "svelte/store"; -export async function obtenerSeguidosPorUsuario(id: string): Promise { +export async function obtenerSeguidosPorUsuario(id: string, limit:number = 20): Promise { try { - const response = await fetch(`${get(apiBase)}/api/users/${id}/following`, { + const response = await fetch(`${get(apiBase)}/api/users/${id}/following?limit=${limit}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/routes/[perfil]/+page.server.ts b/src/routes/[perfil]/+page.server.ts index 9c5399f..f6695b5 100644 --- a/src/routes/[perfil]/+page.server.ts +++ b/src/routes/[perfil]/+page.server.ts @@ -8,8 +8,8 @@ export async function load({ params }) { const usuario: UserResponseDto | null = await obtenerUsuarioPorUsername(params.perfil); if(!usuario) error(404, 'No se encontro el usuario, ' + params.perfil); - const seguidos = await obtenerSeguidosPorUsuario(usuario.id); - const seguidores = await obtenerSeguidoresPorUsuario(usuario.id); + const seguidos = await obtenerSeguidosPorUsuario(usuario.id, 3); + const seguidores = await obtenerSeguidoresPorUsuario(usuario.id, 3); return { ...usuario, seguidos, seguidores }; } diff --git a/src/routes/[perfil]/+page.svelte b/src/routes/[perfil]/+page.svelte index 52ecf28..4ccc71e 100644 --- a/src/routes/[perfil]/+page.svelte +++ b/src/routes/[perfil]/+page.svelte @@ -104,22 +104,38 @@ - Seguidores: + Seguidos: {page.data.seguidos.length} - + {#if page.data.seguidos.length === 0} +

No hay Seguidos

+ {:else} + {#each page.data.seguidos as seguidos (seguidos.id)} +

+ {seguidos.username} +

+ {/each} + {/if}
- Seguidos: + Seguidores: {page.data.seguidores.length} - + {#if page.data.seguidores.length === 0} +

No hay Seguidores

+ {:else} + {#each page.data.seguidores as seguidores (seguidores.id)} +

+ {seguidores.username} +

+ {/each} + {/if}