From cb176306590d6b7529cbc71a4b7a28bc79580191 Mon Sep 17 00:00:00 2001 From: Cheryl Chen Date: Thu, 7 Mar 2024 13:33:36 -0800 Subject: [PATCH] added approved-accounts route --- routes/users.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/routes/users.js b/routes/users.js index 7f2ce2a..707a026 100644 --- a/routes/users.js +++ b/routes/users.js @@ -17,7 +17,20 @@ userRouter.get('/', async (req, res) => { userRouter.get('/pending-accounts', async (req, res) => { try { - const pendingAccounts = await db.query(`SELECT * FROM users WHERE approved = FALSE;`); + const pendingAccounts = await db.query( + `SELECT * FROM users WHERE approved = FALSE ORDER BY first_name ASC;`, + ); + res.status(200).json(keysToCamel(pendingAccounts)); + } catch (err) { + res.status(500).send(err.message); + } +}); + +userRouter.get('/approved-accounts', async (req, res) => { + try { + const pendingAccounts = await db.query( + `SELECT * FROM users WHERE approved = TRUE ORDER BY first_name ASC;`, + ); res.status(200).json(keysToCamel(pendingAccounts)); } catch (err) { res.status(500).send(err.message);