From a50592609f17f95449d1b04b9250a9fa49646785 Mon Sep 17 00:00:00 2001 From: andreasz97 Date: Fri, 27 Sep 2024 12:29:01 +0200 Subject: [PATCH] fix: range check improvement --- src/components/timesheet/TimeSheetTable.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/timesheet/TimeSheetTable.tsx b/src/components/timesheet/TimeSheetTable.tsx index 411ee54..4c2e6f6 100644 --- a/src/components/timesheet/TimeSheetTable.tsx +++ b/src/components/timesheet/TimeSheetTable.tsx @@ -58,7 +58,6 @@ export const TimeSheetTable = component$( timeEntryObject; if (timeEntriesState[project.name][date] !== hours) return false; - // Check if the entry already exists const entryExists = state.dataTimeEntries.find( (entry) => @@ -67,13 +66,19 @@ export const TimeSheetTable = component$( entry.project.name === project.name && entry.project.type === project.type && entry.task.name === task.name && - entry.startHour === startHour && - entry.endHour === endHour && entry.description === description ); - // If the entry exists if (entryExists) { + // If the start/end hours are the same (and exist), then the hours too have not changed + if (startHour !== '00:00' && endHour !== '00:00') { + if ( + entryExists.startHour === startHour && + entryExists.endHour === endHour + ) { + return true; + } + } // Return true if the new hours are the same as the existing hours return entryExists.hours === hours; } else {