From 7f98d526345cbe8f32bd45a935b1f14c032b54c5 Mon Sep 17 00:00:00 2001 From: ajdj100 Date: Mon, 15 Dec 2025 13:12:48 -0500 Subject: [PATCH] fixed error on approve/deny applications --- api/src/routes/applications.ts | 19 ++++++------------- api/src/services/applicationService.ts | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/api/src/routes/applications.ts b/api/src/routes/applications.ts index 3c78aeb..6183c2a 100644 --- a/api/src/routes/applications.ts +++ b/api/src/routes/applications.ts @@ -155,21 +155,13 @@ router.post('/approve/:id', [requireLogin, requireRole("Recruiter")], async (req try { const app = await getApplicationByID(appID); - const result = await approveApplication(appID); - - //guard against failures - if (result.affectedRows != 1) { - throw new Error("Something went wrong approving the application"); - } + await approveApplication(appID, approved_by); //update user profile await setUserState(app.member_id, MemberState.Member); await pool.query('CALL sp_accept_new_recruit_validation(?, ?, ?, ?)', [Number(process.env.CONFIG_ID), app.member_id, approved_by, approved_by]) - // let nextRank = await getRankByName('Recruit') - // await insertMemberRank(app.member_id, nextRank.id); - // //assign user to "pending basic" - // await assignUserToStatus(app.member_id, 1); + res.sendStatus(200); } catch (err) { console.error('Approve failed:', err); @@ -178,12 +170,13 @@ router.post('/approve/:id', [requireLogin, requireRole("Recruiter")], async (req }); // POST /application/deny/:id -router.post('/deny/:id', [requireLogin, requireRole("Recruiter")], async (req, res) => { - const appID = req.params.id; +router.post('/deny/:id', [requireLogin, requireRole("Recruiter")], async (req: Request, res: Response) => { + const appID = Number(req.params.id); + const approver = Number(req.user.id); try { const app = await getApplicationByID(appID); - await denyApplication(appID); + await denyApplication(appID, approver); await setUserState(app.member_id, MemberState.Denied); res.sendStatus(200); } catch (err) { diff --git a/api/src/services/applicationService.ts b/api/src/services/applicationService.ts index dceaad3..85615bc 100644 --- a/api/src/services/applicationService.ts +++ b/api/src/services/applicationService.ts @@ -59,30 +59,35 @@ export async function getAllMemberApplications(memberID: number): Promise