Skip to content

Commit 8fe9384

Browse files
committed
fix: TT-91 Small code corrections
1 parent 48246a4 commit 8fe9384

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
105105
const isStartDateGreaterThanActiveEntry = startDateAsLocalDate > activeEntryAsLocalDate;
106106
const isEndDateGreaterThanActiveEntry = endDateAsLocalDate > activeEntryAsLocalDate;
107107
const isTimeEntryOverlapping = isStartDateGreaterThanActiveEntry || isEndDateGreaterThanActiveEntry;
108-
109-
if (isEditingEntryEqualToActiveEntry) {
110-
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
111-
const overlappingEntry = ds.data.find((item) => {
112-
const itemEndDate = new Date(item.end_date);
113-
return startDateAsLocalDate < itemEndDate;
114-
});
115-
this.isActiveEntryOverlapping = overlappingEntry ? true : false;
116-
});
117-
}
108+
this.checkIfActiveEntryOverlapping(isEditingEntryEqualToActiveEntry, startDateAsLocalDate);
118109
if (!isEditingEntryEqualToActiveEntry && isTimeEntryOverlapping || this.isActiveEntryOverlapping ) {
119110
const message = this.isActiveEntryOverlapping ? 'try another "Time in"' : 'try with earlier times';
120111
this.toastrService.error(`You are on the clock and this entry overlaps it, ${message}.`);
@@ -183,4 +174,16 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
183174
resetDraggablePosition(event: any): void {
184175
event.source._dragRef.reset();
185176
}
177+
178+
checkIfActiveEntryOverlapping(isEditingEntryEqualToActiveEntry: boolean, startDateAsLocalDate: Date) {
179+
if (isEditingEntryEqualToActiveEntry) {
180+
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
181+
const overlappingEntry = ds.data.find((item) => {
182+
const itemEndDate = new Date(item.end_date);
183+
return startDateAsLocalDate < itemEndDate;
184+
});
185+
this.isActiveEntryOverlapping = overlappingEntry ? true : false;
186+
});
187+
}
188+
}
186189
}

0 commit comments

Comments
 (0)