mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-14 15:20:45 -03:00
add pagination in following and followers
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user