fixed an error in application loading
This commit is contained in:
@@ -49,21 +49,14 @@ router.get('/me', async (req, res) => {
|
|||||||
// GET /application/:id
|
// GET /application/:id
|
||||||
router.get('/:id', async (req, res) => {
|
router.get('/:id', async (req, res) => {
|
||||||
let appID = req.params.id;
|
let appID = req.params.id;
|
||||||
|
console.log("HELLO")
|
||||||
try {
|
try {
|
||||||
const conn = await pool.getConnection()
|
|
||||||
|
|
||||||
const application = await getApplicationByID(appID);
|
const application = await getApplicationByID(appID);
|
||||||
|
if (application === undefined)
|
||||||
if (!Array.isArray(application) || application.length === 0) {
|
return res.sendStatus(204);
|
||||||
conn.release();
|
|
||||||
return res.status(204).json("Application Not Found");
|
|
||||||
}
|
|
||||||
|
|
||||||
const comments: CommentRow[] = await getApplicationComments(appID);
|
const comments: CommentRow[] = await getApplicationComments(appID);
|
||||||
|
|
||||||
conn.release()
|
|
||||||
|
|
||||||
const output: ApplicationFull = {
|
const output: ApplicationFull = {
|
||||||
application,
|
application,
|
||||||
comments,
|
comments,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export interface ApplicationRow {
|
|||||||
approved_at: string | null;
|
approved_at: string | null;
|
||||||
denied_at: string | null;
|
denied_at: string | null;
|
||||||
|
|
||||||
app_status: Status; // generated column
|
app_status: ApplicationStatus; // generated column
|
||||||
decision_at: string | null; // generated column
|
decision_at: string | null; // generated column
|
||||||
|
|
||||||
// present when you join members (e.g., SELECT a.*, m.name AS member_name)
|
// present when you join members (e.g., SELECT a.*, m.name AS member_name)
|
||||||
@@ -54,4 +54,10 @@ export interface ApplicationListRow {
|
|||||||
member_name: string | null; // because LEFT JOIN means it might be null
|
member_name: string | null; // because LEFT JOIN means it might be null
|
||||||
submitted_at: Date;
|
submitted_at: Date;
|
||||||
app_status: string; // or enum if you have one
|
app_status: string; // or enum if you have one
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ApplicationStatus {
|
||||||
|
Pending = "Pending",
|
||||||
|
Accepted = "Accepted",
|
||||||
|
Denied = "Denied",
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user