From 4bb21633ee1eaba38bb0c2cfeb726012a4aefacf Mon Sep 17 00:00:00 2001 From: margoglvz Date: Thu, 2 Jan 2025 23:02:40 -0800 Subject: [PATCH] added GET /comments/booking/:id --- server/routes/comments.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/routes/comments.ts b/server/routes/comments.ts index 49e9c06..a4e9181 100644 --- a/server/routes/comments.ts +++ b/server/routes/comments.ts @@ -28,3 +28,14 @@ commentsRouter.get("/invoice/:id", async (req, res) => { } }); +// GET /comments/booking/:id +// Returns all comments that much up that invoice ID +commentsRouter.get("/booking/:id", async (req, res) => { + try { + const {id} = req.params; + const data = await db.query("SELECT * FROM comments WHERE booking_id = $1", [id]); + res.status(200).json(keysToCamel(data)); + } catch (err) { + res.status(500).send(err.message); + } +});