Skip to content

Commit bcb92d4

Browse files
committed
fix: #336 fix automatic clock outs
1 parent 609d97d commit bcb92d4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/app/modules/time-clock/store/entry.actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class DeleteEntryFail implements Action {
115115
export class UpdateActiveEntry implements Action {
116116
public readonly type = EntryActionTypes.UPDATE_ACTIVE_ENTRY;
117117

118-
constructor(public payload: NewEntry) {}
118+
constructor(public payload) {}
119119
}
120120

121121
export class UpdateActiveEntrySuccess implements Action {

src/app/modules/time-clock/store/entry.effects.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as actions from './entry.actions';
1010

1111
@Injectable()
1212
export class EntryEffects {
13-
constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) {}
13+
constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) { }
1414

1515
@Effect()
1616
loadEntriesSummary$: Observable<Action> = this.actions$.pipe(
@@ -36,17 +36,16 @@ export class EntryEffects {
3636
map((activeEntry) => {
3737
if (activeEntry) {
3838
const today = new Date();
39-
const entryStartDate = new Date (activeEntry.start_date);
39+
const entryStartDate = new Date(activeEntry.start_date);
4040
const isSameDay = (today.getDate() === entryStartDate.getDate()
41-
&& today.getMonth() === entryStartDate.getMonth()
42-
&& today.getFullYear() === entryStartDate.getFullYear());
41+
&& today.getMonth() === entryStartDate.getMonth()
42+
&& today.getFullYear() === entryStartDate.getFullYear());
4343
if (isSameDay) {
4444
return new actions.LoadActiveEntrySuccess(activeEntry);
4545
} else {
46-
const endDate = activeEntry.start_date;
46+
const endDate = new Date(activeEntry.start_date);
4747
endDate.setHours(23, 59, 59);
48-
activeEntry.end_date = endDate.toISOString();
49-
return new actions.UpdateActiveEntry(activeEntry);
48+
return new actions.UpdateActiveEntry({ d: activeEntry.id, end_date: endDate.toISOString() });
5049
}
5150
}
5251
}),
@@ -119,7 +118,7 @@ export class EntryEffects {
119118
mergeMap((entry) =>
120119
this.entryService.updateActiveEntry(entry).pipe(
121120
map((entryResponse) => {
122-
if (entryResponse.end_date) {
121+
if (entryResponse.end_date && entry.start_date === null) {
123122
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
124123
}
125124
return new actions.UpdateActiveEntrySuccess(entryResponse);

0 commit comments

Comments
 (0)