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

@@ -8,12 +8,15 @@ export async function commandListController(req, res) {
const itemsPerPage = 100
try {
const payload = await errorCommands(
new Pagination(order, itemsPerPage, nextKey)
)
const pagination = new Pagination(order, itemsPerPage, nextKey)
const payload = await errorCommands(pagination)
const newNextKey = payload[payload.length - 1]?._id
res.render('commands', { errorCommands: payload, nextKey: newNextKey })
res.render('commands', {
errorCommands: payload,
nextKey: newNextKey,
order: pagination.getOrder(),
})
} catch (error) {
console.error(error)
res.status(500).send('Error fetching data')