added support for course name in course_event details

This commit is contained in:
2025-11-16 23:40:06 -05:00
parent 5387306d93
commit 1d35fe1cf5
2 changed files with 2 additions and 2 deletions

View File

@@ -51,7 +51,7 @@ export async function getCourseEventAttendees(id: number): Promise<CourseAttende
}
export async function getCourseEventDetails(id: number): Promise<CourseEventDetails> {
const sql = `SELECT * FROM course_events WHERE id = ?;`;
const sql = `SELECT E.*, C.name AS course_name FROM course_events AS E LEFT JOIN courses AS C ON E.course_id = C.id WHERE E.id = ?;`;
let rows: CourseEventDetails[] = await pool.query(sql, [id]);
let event = rows[0];
event.attendees = await getCourseEventAttendees(id);
@@ -74,7 +74,6 @@ export async function insertCourseEvent(event: CourseEventDetails): Promise<numb
remarks
)
VALUES (?, ?, ?, ?, ?);`, [attendee.attendee_id, eventID, attendee.attendee_role_id, attendee.passed, attendee.remarks]);
}
await con.commit();
} catch (error) {

View File

@@ -29,6 +29,7 @@ export interface CourseEventDetails {
attendees: CourseAttendee[] | null;
created_by: number | null;
course_name: string | null;
}