fixed error on approve/deny applications
This commit is contained in:
@@ -59,30 +59,35 @@ export async function getAllMemberApplications(memberID: number): Promise<Applic
|
||||
}
|
||||
|
||||
|
||||
export async function approveApplication(id: number) {
|
||||
export async function approveApplication(id: number, approver: number) {
|
||||
const sql = `
|
||||
UPDATE applications
|
||||
SET approved_at = NOW()
|
||||
SET approved_at = NOW(), approved_by = ?
|
||||
WHERE id = ?
|
||||
AND approved_at IS NULL
|
||||
AND denied_at IS NULL
|
||||
`;
|
||||
|
||||
const result = await pool.execute(sql, id);
|
||||
return result;
|
||||
const result = await pool.execute(sql, [approver, id]);
|
||||
console.log(result);
|
||||
if (result.affectedRows == 1) {
|
||||
return
|
||||
} else {
|
||||
throw new Error(`"Something went wrong approving application with ID ${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function denyApplication(id: number) {
|
||||
export async function denyApplication(id: number, approver: number) {
|
||||
const sql = `
|
||||
UPDATE applications
|
||||
SET denied_at = NOW()
|
||||
SET denied_at = NOW(), approved_by = ?
|
||||
WHERE id = ?
|
||||
AND approved_at IS NULL
|
||||
AND denied_at IS NULL
|
||||
`;
|
||||
|
||||
const result = await pool.execute(sql, id);
|
||||
|
||||
const result = await pool.execute(sql, [approver, id]);
|
||||
console.log(result);
|
||||
if (result.affectedRows == 1) {
|
||||
return
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user