Fixed hardcoded value in application comment poster
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user