From 3dc8aea5406b7015ed7df9cb60fe8e6d058f3aeb Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Tue, 25 Jun 2024 15:32:05 -0700 Subject: [PATCH] Fixes --- api/src/routes/report-router.ts | 4 +--- api/src/routes/role-router.ts | 7 +++++-- api/src/utils/formatters.ts | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/src/routes/report-router.ts b/api/src/routes/report-router.ts index 98eced2..9005adb 100644 --- a/api/src/routes/report-router.ts +++ b/api/src/routes/report-router.ts @@ -70,8 +70,6 @@ reportRouter.post("/", async (req: Request, res: Response) => { let insertedId = insertedReports[0].id; - console.log("req.file", req.files); - if (req.files && req.files.files) { let files = req.files.files; @@ -93,5 +91,5 @@ reportRouter.post("/", async (req: Request, res: Response) => { } } - return res.status(500).json({ data: [] }); + return res.status(200).json({ data: {} }); }); diff --git a/api/src/routes/role-router.ts b/api/src/routes/role-router.ts index b7d2c32..c4c459c 100644 --- a/api/src/routes/role-router.ts +++ b/api/src/routes/role-router.ts @@ -23,8 +23,11 @@ roleRouter.post("/user/:user_id", async (req: Request, res: Response) => { for (const role of roles) { role.create_user_id = req.user.id; - role.start_date = InsertableDate(role.start_date); - role.end_date = InsertableDate(role.end_date); + + // TODO: implement date-based activations if necessary + //role.start_date = InsertableDate(role.start_date); + //role.end_date = InsertableDate(role.end_date); + role.created_at = InsertableDate(new Date().toISOString()); if (isEmpty(role.department_code)) role.department_code = null; await trx("user_roles").insert(roleForInsert(role)); diff --git a/api/src/utils/formatters.ts b/api/src/utils/formatters.ts index 93ee4c4..d3ce932 100644 --- a/api/src/utils/formatters.ts +++ b/api/src/utils/formatters.ts @@ -47,6 +47,8 @@ export function RenderMarkdown(input: string): { output: string; isMarkdown: boo export function InsertableDate(input: string | null) { if (input) { if (DB_CLIENT == "oracledb") { + console.log("CONVERTING FOR ORACLE", input); + return knex.raw( `TO_TIMESTAMP('${DateTime.fromISO(input).toFormat("yyyy-MM-dd HH:mm:ss")}', 'YYYY-MM-DD HH24:MI:SS')` );