Fixed hardcoded value in application comment poster

This commit is contained in:
2025-12-08 16:15:34 -05:00
parent 6a55846f19
commit 4ab803ec72
4 changed files with 33 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
import { ApplicationListRow, ApplicationRow, CommentRow } from "@app/shared/types/application";
import pool from "../db";
import { error } from "console";
export async function createApplication(memberID: number, appVersion: number, app: string) {
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
@@ -44,7 +45,7 @@ export async function getApplicationList(): Promise<ApplicationListRow[]> {
return rows;
}
export async function approveApplication(id) {
export async function approveApplication(id: number) {
const sql = `
UPDATE applications
SET approved_at = NOW()
@@ -57,6 +58,24 @@ export async function approveApplication(id) {
return result;
}
export async function denyApplication(id: number) {
const sql = `
UPDATE applications
SET denied_at = NOW()
WHERE id = ?
AND approved_at IS NULL
AND denied_at IS NULL
`;
const result = await pool.execute(sql, id);
if (result.affectedRows == 1) {
return
} else {
throw new Error(`"Something went wrong denying application with ID ${id}`);
}
}
export async function getApplicationComments(appID: number): Promise<CommentRow[]> {
return await pool.query(`SELECT app.id AS comment_id,
app.post_content,