Skip to content

Commit

Permalink
added query in pending accounts for admin and student
Browse files Browse the repository at this point in the history
  • Loading branch information
chloecheng8 committed Apr 21, 2024
1 parent d21f633 commit c8fe1a2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c8fe1a2

Please sign in to comment.