Updated application acceptance system
This commit is contained in:
@@ -141,8 +141,9 @@ router.get('/:id', async (req: Request, res: Response) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// POST /application/approve/:id
|
// POST /application/approve/:id
|
||||||
router.post('/approve/:id', async (req, res) => {
|
router.post('/approve/:id', async (req: Request, res: Response) => {
|
||||||
const appID = req.params.id;
|
const appID = Number(req.params.id);
|
||||||
|
const approved_by = req.user.id;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const app = await getApplicationByID(appID);
|
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");
|
throw new Error("Something went wrong approving the application");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(app.member_id);
|
|
||||||
//update user profile
|
//update user profile
|
||||||
await setUserState(app.member_id, MemberState.Member);
|
await setUserState(app.member_id, MemberState.Member);
|
||||||
|
|
||||||
let nextRank = await getRankByName('Recruit')
|
await pool.query('CALL sp_accept_new_recruit(?, ?, ?, ?)', [Number(process.env.CONFIG_ID), app.member_id, approved_by, approved_by])
|
||||||
await insertMemberRank(app.member_id, nextRank.id);
|
// let nextRank = await getRankByName('Recruit')
|
||||||
//assign user to "pending basic"
|
// await insertMemberRank(app.member_id, nextRank.id);
|
||||||
await assignUserToStatus(app.member_id, 1);
|
// //assign user to "pending basic"
|
||||||
|
// await assignUserToStatus(app.member_id, 1);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Approve failed:', err);
|
console.error('Approve failed:', err);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export async function getMyApplication(id: number): Promise<ApplicationFull> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function approveApplication(id: Number) {
|
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) {
|
if (!res.ok) {
|
||||||
console.error("Something went wrong approving the application")
|
console.error("Something went wrong approving the application")
|
||||||
@@ -97,7 +97,7 @@ export async function approveApplication(id: Number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function denyApplication(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) {
|
if (!res.ok) {
|
||||||
console.error("Something went wrong denying the application")
|
console.error("Something went wrong denying the application")
|
||||||
|
|||||||
Reference in New Issue
Block a user