From 5b102670140c6a64cd7cee78a84368b58facb754 Mon Sep 17 00:00:00 2001 From: Luke Liew Mouawad Date: Wed, 10 Apr 2024 00:24:07 +0100 Subject: [PATCH] fixed bug where start time could be later than end time in resubmit --- .../View_Saved_Timesheets_Page/TimesheetCard.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/Components/View_Saved_Timesheets_Page/TimesheetCard.js b/frontend/src/Components/View_Saved_Timesheets_Page/TimesheetCard.js index 8b062525..57bfad52 100644 --- a/frontend/src/Components/View_Saved_Timesheets_Page/TimesheetCard.js +++ b/frontend/src/Components/View_Saved_Timesheets_Page/TimesheetCard.js @@ -8,7 +8,21 @@ export default function TimesheetCard(props) { const [hasResubmitted, setHasResubmitted] = useState(false) function resubmitTimesheet() { - if (hasResubmitted != true) { + var newStartTimeDate = new Date() + var newEndTimeDate = new Date() + + const [newStartHours, newStartMins, newStartSecs] = newStartTime.split(":").map(Number) + const [newEndHours, newEndMins, newEndSecs] = newEndTime.split(":").map(Number) + + newStartTimeDate.setHours(newStartHours) + newStartTimeDate.setMinutes(newStartMins) + newStartTimeDate.setSeconds(newStartSecs) + + newEndTimeDate.setHours(newEndHours) + newEndTimeDate.setMinutes(newEndMins) + newEndTimeDate.setSeconds(newEndSecs) + console.log(newStartTimeDate, newEndTimeDate, newStartTimeDate