From 0a1704b60bdf2f09b4912241c93a40854d1bf36a Mon Sep 17 00:00:00 2001 From: ajdj100 Date: Thu, 11 Dec 2025 21:43:49 -0500 Subject: [PATCH] Updated application acceptance system --- api/src/routes/applications.ts | 15 ++++++++------- ui/src/api/application.ts | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/src/routes/applications.ts b/api/src/routes/applications.ts index c79514e..718a92b 100644 --- a/api/src/routes/applications.ts +++ b/api/src/routes/applications.ts @@ -141,8 +141,9 @@ router.get('/:id', async (req: Request, res: Response) => { }); // POST /application/approve/:id -router.post('/approve/:id', async (req, res) => { - const appID = req.params.id; +router.post('/approve/:id', async (req: Request, res: Response) => { + const appID = Number(req.params.id); + const approved_by = req.user.id; try { const app = await getApplicationByID(appID); @@ -153,14 +154,14 @@ router.post('/approve/:id', async (req, res) => { throw new Error("Something went wrong approving the application"); } - console.log(app.member_id); //update user profile await setUserState(app.member_id, MemberState.Member); - let nextRank = await getRankByName('Recruit') - await insertMemberRank(app.member_id, nextRank.id); - //assign user to "pending basic" - await assignUserToStatus(app.member_id, 1); + await pool.query('CALL sp_accept_new_recruit(?, ?, ?, ?)', [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); diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index 8f60f1e..ca1b52b 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -89,7 +89,7 @@ export async function getMyApplication(id: number): Promise { } export async function approveApplication(id: Number) { - const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST' }) + const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST', credentials: 'include' }) if (!res.ok) { console.error("Something went wrong approving the application") @@ -97,7 +97,7 @@ export async function approveApplication(id: Number) { } export async function denyApplication(id: Number) { - const res = await fetch(`${addr}/application/deny/${id}`, { method: 'POST' }) + const res = await fetch(`${addr}/application/deny/${id}`, { method: 'POST', credentials: 'include' }) if (!res.ok) { console.error("Something went wrong denying the application")