Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions backend/endpoints/report/controller/getDailyOverviewReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions frontend/app/components/Overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading