Skip to content

Commit 97a5517

Browse files
author
Guido Quezada
committed
TT-00 fix: refactor condition
1 parent 5cbe799 commit 97a5517

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
105105
const endDateAsLocalDate = new Date(event.entry.end_date);
106106
const activeEntryAsLocalDate = new Date(this.activeTimeEntry.start_date);
107107
const isEditingEntryEqualToActiveEntry = this.entryId === this.activeTimeEntry.id;
108-
const isStartDateLowerThanActiveEntry = startDateAsLocalDate < activeEntryAsLocalDate;
109-
const isEndDateLowerThanActiveEntry = endDateAsLocalDate < activeEntryAsLocalDate;
110-
if(isEditingEntryEqualToActiveEntry && (isStartDateLowerThanActiveEntry || isEndDateLowerThanActiveEntry)){
111-
this.doSave(event);
112-
} else {
108+
const isStartDateGreaterThanActiveEntry = startDateAsLocalDate > activeEntryAsLocalDate;
109+
const isEndDateGreaterThanActiveEntry = endDateAsLocalDate > activeEntryAsLocalDate;
110+
if(!isEditingEntryEqualToActiveEntry && (isStartDateGreaterThanActiveEntry || isEndDateGreaterThanActiveEntry)){
113111
this.toastrService.error('You are on the clock and this entry overlaps it, try with earlier times.');
112+
} else {
113+
this.doSave(event);
114114
}
115115
} else {
116116
this.doSave(event);

0 commit comments

Comments
 (0)