diff --git a/src/app/modules/time-clock/store/entry.actions.ts b/src/app/modules/time-clock/store/entry.actions.ts index 5783a76a2..ee07d1f0a 100644 --- a/src/app/modules/time-clock/store/entry.actions.ts +++ b/src/app/modules/time-clock/store/entry.actions.ts @@ -115,7 +115,7 @@ export class DeleteEntryFail implements Action { export class UpdateActiveEntry implements Action { public readonly type = EntryActionTypes.UPDATE_ACTIVE_ENTRY; - constructor(public payload: NewEntry) {} + constructor(public payload) {} } export class UpdateActiveEntrySuccess implements Action { diff --git a/src/app/modules/time-clock/store/entry.effects.ts b/src/app/modules/time-clock/store/entry.effects.ts index e41018e29..99a5a3fb6 100644 --- a/src/app/modules/time-clock/store/entry.effects.ts +++ b/src/app/modules/time-clock/store/entry.effects.ts @@ -10,7 +10,7 @@ import * as actions from './entry.actions'; @Injectable() export class EntryEffects { - constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) {} + constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) { } @Effect() loadEntriesSummary$: Observable = this.actions$.pipe( @@ -36,17 +36,16 @@ export class EntryEffects { map((activeEntry) => { if (activeEntry) { const today = new Date(); - const entryStartDate = new Date (activeEntry.start_date); + const entryStartDate = new Date(activeEntry.start_date); const isSameDay = (today.getDate() === entryStartDate.getDate() - && today.getMonth() === entryStartDate.getMonth() - && today.getFullYear() === entryStartDate.getFullYear()); + && today.getMonth() === entryStartDate.getMonth() + && today.getFullYear() === entryStartDate.getFullYear()); if (isSameDay) { return new actions.LoadActiveEntrySuccess(activeEntry); } else { - const endDate = activeEntry.start_date; + const endDate = new Date(activeEntry.start_date); endDate.setHours(23, 59, 59); - activeEntry.end_date = endDate.toISOString(); - return new actions.UpdateActiveEntry(activeEntry); + return new actions.UpdateActiveEntry({ d: activeEntry.id, end_date: endDate.toISOString() }); } } }), @@ -119,7 +118,7 @@ export class EntryEffects { mergeMap((entry) => this.entryService.updateActiveEntry(entry).pipe( map((entryResponse) => { - if (entryResponse.end_date) { + if (entryResponse.end_date && entry.start_date === null) { this.toastrService.success(INFO_SAVED_SUCCESSFULLY); } return new actions.UpdateActiveEntrySuccess(entryResponse);