added support for optional checkboxes

This commit is contained in:
2025-11-20 14:27:34 -05:00
parent 23ebbe7a85
commit d9e4c1d6ff
4 changed files with 46 additions and 14 deletions

View File

@@ -4,14 +4,21 @@ import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails, CourseE
export async function getAllCourses(): Promise<Course[]> {
const sql = "SELECT * FROM courses WHERE deleted = false;"
const res = await pool.query(sql);
const res: Course[] = await pool.query(sql);
return res;
}
export async function getCourseByID(id: number): Promise<Course> {
const sql = "SELECT * FROM courses WHERE id = ?;"
const res: Course[] = await pool.query(sql, [id]);
return res[0];
}
function buildAttendee(row: RawAttendeeRow): CourseAttendee {
return {
passed: !!row.passed,
passed_bookwork: !!row.passed_bookwork,
passed_qual: !!row.passed_qual,
attendee_id: row.attendee_id,
course_event_id: row.course_event_id,
created_at: row.created_at,
@@ -67,6 +74,7 @@ export async function getCourseEventDetails(id: number): Promise<CourseEventDeta
let rows: CourseEventDetails[] = await pool.query(sql, [id]);
let event = rows[0];
event.attendees = await getCourseEventAttendees(id);
event.course = await getCourseByID(event.course_id);
return event;
}
@@ -83,10 +91,11 @@ export async function insertCourseEvent(event: CourseEventDetails): Promise<numb
attendee_id,
course_event_id,
attendee_role_id,
passed,
passed_bookwork,
passed_qual,
remarks
)
VALUES (?, ?, ?, ?, ?);`, [attendee.attendee_id, eventID, attendee.attendee_role_id, attendee.passed, attendee.remarks]);
VALUES (?, ?, ?, ?, ?);`, [attendee.attendee_id, eventID, attendee.attendee_role_id, attendee.passed_bookwork, attendee.passed_qual, attendee.remarks]);
}
await con.commit();
await con.release();