diff --git a/routes/users.js b/routes/users.js index 6abf3dc..5abfc9c 100644 --- a/routes/users.js +++ b/routes/users.js @@ -17,9 +17,14 @@ userRouter.get('/', async (req, res) => { userRouter.get('/pending-accounts', async (req, res) => { try { - const pendingAccounts = await db.query( - `SELECT * FROM users WHERE approved = FALSE ORDER BY first_name ASC;`, - ); + const { accountType } = req.query; + let queryString = 'SELECT * FROM users WHERE approved = FALSE '; + if (accountType === 'admin') { + queryString += `AND type = 'admin'`; + } else if (accountType === 'student') { + queryString += `AND type = 'student'`; + } + const pendingAccounts = await db.query(`${queryString} ORDER BY first_name ASC;`); res.status(200).json(keysToCamel(pendingAccounts)); } catch (err) { res.status(500).send(err.message);