Skip to content

Commit

Permalink
fix: range check improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasz97 committed Sep 27, 2024
1 parent 315b44f commit a505926
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/timesheet/TimeSheetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const TimeSheetTable = component$<TimeSheetTableProps>(
timeEntryObject;

if (timeEntriesState[project.name][date] !== hours) return false;

// Check if the entry already exists
const entryExists = state.dataTimeEntries.find(
(entry) =>
Expand All @@ -67,13 +66,19 @@ export const TimeSheetTable = component$<TimeSheetTableProps>(
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 {
Expand Down

0 comments on commit a505926

Please sign in to comment.