From d49e349ccbfbd6f36fdbe4e7263989cb755e35ff Mon Sep 17 00:00:00 2001 From: cherhchen <54284307+cherhchen@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:26:57 -0700 Subject: [PATCH] added approved-accounts route (#59) Co-authored-by: Cheryl Chen Co-authored-by: ThatMegamind <92563733+ThatMegamind@users.noreply.github.com> --- 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);