application-dp-upgrade #66
@@ -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);
|
||||
|
||||
@@ -89,7 +89,7 @@ export async function getMyApplication(id: number): Promise<ApplicationFull> {
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user