feat: add pagination buttons

This commit is contained in:
Chen, Tai-Lin committed 2023-12-21 17:48:36 +08:00
1 parent fa36b63fbe
commit 3b68693177
8 files changed
+52 -19

No files matched your search

+7 -2
View File
@@ -6,10 +6,15 @@ export async function userListController(req, res) {
const itemsPerPage = 50
try {
const users = await userList(new Pagination(order, itemsPerPage, nextKey))
const pagination = new Pagination(order, itemsPerPage, nextKey)
const users = await userList(pagination)
const newNextKey = users[users.length - 1]?._id
res.render('users', { users, nextKey: newNextKey })
res.render('users', {
users,
nextKey: newNextKey,
order: pagination.getOrder(),
})
} catch (error) {
console.error(error)
res.status(500).send('Error fetching user data')