From f9b18122fda9c235c8d0b0907908d64111d3b0e0 Mon Sep 17 00:00:00 2001 From: acegoal07 <39467245+acegoal07@users.noreply.github.com> Date: Thu, 9 Jul 2026 09:42:33 +0100 Subject: [PATCH] checks date more and removes debug from overview --- .../controller/getDailyOverviewReport.js | 29 ++++++++++++++----- frontend/app/components/Overview.jsx | 4 --- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/backend/endpoints/report/controller/getDailyOverviewReport.js b/backend/endpoints/report/controller/getDailyOverviewReport.js index 95d6f82..d533902 100644 --- a/backend/endpoints/report/controller/getDailyOverviewReport.js +++ b/backend/endpoints/report/controller/getDailyOverviewReport.js @@ -11,13 +11,28 @@ module.exports = (db) => { */ return async (req, res) => { try { - const { date } = req.query || {}; + const { date: rawDate } = req.query || {}; // Check date - if (typeof date !== 'string') { - return res - .status(400) - .json({ success: false, error: 'The date provided is not a string' }); + let date = null; + if (rawDate !== undefined && rawDate !== null) { + console.log(`hello ${rawDate}`); + + if (typeof rawDate !== 'string') { + return res + .status(400) + .json({ success: false, error: 'The date provided is not a string' }); + } + + let tmpDate = rawDate.trim(); + + if (tmpDate) { + tmpDate = new Date(tmpDate); + if (isNaN(tmpDate.getTime())) { + return res.status(400).json({ success: false, error: 'Invalid date provided' }); + } + date = tmpDate; + } } // Get people @@ -45,7 +60,7 @@ module.exports = (db) => { ); // Get the overview report for today or a provided day - const startOfDay = date ? new Date(date) : new Date(); + const startOfDay = date || new Date(); startOfDay.setHours(0, 0, 0, 0); const endOfDay = new Date(startOfDay); @@ -59,7 +74,7 @@ module.exports = (db) => { }); if (!overviewReport) { - return res.status(404).json({ success: false, error: 'There is no overview report' }); + return res.status(200).json({ success: true, body: {} }); } // Get reports diff --git a/frontend/app/components/Overview.jsx b/frontend/app/components/Overview.jsx index f0e906a..aac42c9 100644 --- a/frontend/app/components/Overview.jsx +++ b/frontend/app/components/Overview.jsx @@ -52,10 +52,6 @@ export default function Overview() { loadReportFromDate(); }, [date]); - useEffect(() => { - console.log(report); - }, [report]); - // Calculate duration function calculateDuration(start, end) { const diffMs = end.getTime() - start.getTime();