fixed error on approve/deny applications

This commit is contained in:
2025-12-15 13:12:48 -05:00
parent a73431f622
commit 7f98d52634
2 changed files with 19 additions and 21 deletions

View File

@@ -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 {