Skip to content

Commit

Permalink
fixed bug where start time could be later than end time in resubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Liew Mouawad committed Apr 9, 2024
1 parent 771c3cc commit 5b10267
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<newEndTimeDate)
if (hasResubmitted != true && newStartTimeDate<newEndTimeDate) {
if (/^(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/.test(newStartTime) && /^(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/.test(newEndTime)) {
console.log("Resubmitting timesheet " + props.id)
fetch('http://127.0.0.1:5000/update_timesheet/' + props.id, {
Expand Down

0 comments on commit 5b10267

Please sign in to comment.