add pagination in following and followers

This commit is contained in:
Fran
2026-01-24 09:02:49 -03:00
parent 9eb92b0c06
commit 54593dd2eb
8 changed files with 136 additions and 20 deletions

View File

@@ -35,8 +35,5 @@
<BotonSeguir post={{ authorId: usu.id }} />
</div>
</div>
{#if usu.bio}
<div class="mt-4 rounded-full bg-accent p-4 text-muted-foreground">{usu.bio}</div>
{/if}
</CardContent>
</Card>

View File

@@ -1,16 +1,19 @@
import { sesionStore } from '@/stores/usuario';
import type { UsersResponseDto } from '../../types';
import { get } from 'svelte/store';
import { apiBase } from '@/stores/url';
import { get } from 'svelte/store';
export async function obtenerSeguidoresPorUsuario(
id: string,
page: number = 1,
limit: number = 20,
fetch2: Function
fetch2?: Function
): Promise<UsersResponseDto | null> {
try {
const fetchFunc = fetch2 || fetch;
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/followers?limit=${limit}`, {
const skip = (page - 1) * limit;
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/followers?skip=${skip}&limit=${limit}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -27,4 +30,4 @@ export async function obtenerSeguidoresPorUsuario(
} catch (error) {
return null;
}
}
}

View File

@@ -5,13 +5,15 @@ import { get } from 'svelte/store';
export async function obtenerSeguidosPorUsuario(
id: string,
page: number = 1,
limit: number = 20,
fetch2?: Function
): Promise<UsersResponseDto | null> {
try {
const fetchFunc = fetch2 || fetch;
const skip = (page - 1) * limit;
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/following?limit=${limit}`, {
const response = await fetchFunc(`${get(apiBase)}/api/users/${id}/following?skip=${skip}&limit=${limit}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -23,9 +25,9 @@ export async function obtenerSeguidosPorUsuario(
return null;
}
const users: UsersResponseDto = await response.json();
return users;
const data: UsersResponseDto = await response.json();
return data;
} catch (error) {
return null;
}
}
}