mirror of
https://github.com/Floriansylvain/SnippetsManager.git
synced 2026-10-19 00:34:11 +02:00
Improved getPaginationLinks readability
This commit is contained in:
1 parent
904d039308
commit
f495ebd5f3
1 file changed
+5
-4
@@ -11,10 +11,11 @@ export const queryPaginationParser = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export function getPaginationLinks(query: Pagination, routeName: string): object {
|
export function getPaginationLinks(query: Pagination, routeName: string): object {
|
||||||
|
const nextStart = query.skip + query.take
|
||||||
|
const prevStart = Math.max(0, query.skip - query.take)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
next: `/v1/${routeName}?start=${query.skip + query.take}&per_page=${query.take}`,
|
next: `/v1/${routeName}?start=${nextStart}&per_page=${query.take}`,
|
||||||
prev: `/v1/${routeName}?start=${Math.max(0, query.skip - query.take)}&per_page=${
|
prev: `/v1/${routeName}?start=${prevStart}&per_page=${query.take}`,
|
||||||
query.take
|
|
||||||
}`,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user