Add pagination + update layout of followers
This commit is contained in:
@@ -197,3 +197,17 @@ export function checkUrlPathForDisplay() {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function paginateArray(items, page, perPage) {
|
||||
const offset = perPage * (page - 1);
|
||||
const totalPages = Math.ceil(items.length / perPage);
|
||||
const paginatedItems = items.slice(offset, perPage * page);
|
||||
|
||||
return {
|
||||
previousPage: page - 1 ? page - 1 : null,
|
||||
nextPage: totalPages > page ? page + 1 : null,
|
||||
total: items.length,
|
||||
totalPages: totalPages,
|
||||
items: paginatedItems,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user