Improved the performance of the MasterCorporate

This commit is contained in:
Tiago Ribeiro
2024-09-07 17:34:41 +01:00
parent 56f374bbfe
commit 3be0d158e3
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});