Integrated new time handling system
This commit is contained in:
@@ -76,6 +76,7 @@ eventRouter.post('/', async (req: Request, res: Response) => {
|
||||
console.log();
|
||||
let data: CourseEventDetails = req.body;
|
||||
data.created_by = posterID;
|
||||
data.event_date = new Date(data.event_date);
|
||||
const id = await insertCourseEvent(data);
|
||||
res.status(201).json(id);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pool from "../db"
|
||||
import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails, CourseEventSummary, RawAttendeeRow } from "@app/shared/types/course"
|
||||
|
||||
import { toDateTime } from "@app/shared/utils/time";
|
||||
export async function getAllCourses(): Promise<Course[]> {
|
||||
const sql = "SELECT * FROM courses WHERE deleted = false;"
|
||||
|
||||
@@ -21,8 +21,8 @@ function buildAttendee(row: RawAttendeeRow): CourseAttendee {
|
||||
passed_qual: !!row.passed_qual,
|
||||
attendee_id: row.attendee_id,
|
||||
course_event_id: row.course_event_id,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
created_at: new Date(row.created_at),
|
||||
updated_at: new Date(row.updated_at),
|
||||
remarks: row.remarks,
|
||||
attendee_role_id: row.attendee_role_id,
|
||||
attendee_name: row.attendee_name,
|
||||
@@ -32,8 +32,8 @@ function buildAttendee(row: RawAttendeeRow): CourseAttendee {
|
||||
name: row.role_name,
|
||||
description: row.role_description,
|
||||
deleted: !!row.role_deleted,
|
||||
created_at: row.role_created_at,
|
||||
updated_at: row.role_updated_at,
|
||||
created_at: new Date(row.role_created_at),
|
||||
updated_at: new Date(row.role_updated_at),
|
||||
}
|
||||
: null
|
||||
};
|
||||
@@ -83,7 +83,7 @@ export async function insertCourseEvent(event: CourseEventDetails): Promise<numb
|
||||
const con = await pool.getConnection();
|
||||
try {
|
||||
await con.beginTransaction();
|
||||
const res = await con.query("INSERT INTO course_events (course_id, event_date, remarks, created_by) VALUES (?, ?, ?, ?);", [event.course_id, event.event_date, event.remarks, event.created_by]);
|
||||
const res = await con.query("INSERT INTO course_events (course_id, event_date, remarks, created_by) VALUES (?, ?, ?, ?);", [event.course_id, toDateTime(event.event_date), event.remarks, event.created_by]);
|
||||
var eventID: number = res.insertId;
|
||||
|
||||
for (const attendee of event.attendees) {
|
||||
|
||||
Reference in New Issue
Block a user