Merge branch 'migration-mongodb' of https://bitbucket.org/ecropdev/ielts-ui into migration-mongodb

This commit is contained in:
Carlos Mesquita
2024-09-07 17:54:19 +01:00
11 changed files with 1197 additions and 1134 deletions

View File

@@ -13,8 +13,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return;
}
const {size, type, page} = req.query as {size?: string; type?: Type; page?: string};
console.log(size, type, page);
const {
size,
type,
page,
orderBy,
direction = "desc",
} = req.query as {size?: string; type?: Type; page?: string; orderBy?: string; direction?: "asc" | "desc"};
const {users, total} = await getLinkedUsers(
req.session.user?.id,
@@ -22,6 +27,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
type,
page !== undefined ? parseInt(page) : undefined,
size !== undefined ? parseInt(size) : undefined,
orderBy,
direction,
);
res.status(200).json({users, total});