Skip to content

Commit 1b0e548

Browse files
author
Juan Gabriel Guzman
committed
feat: #333 Enabling toastr messages when updating time entries
1 parent a006e26 commit 1b0e548

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from './../../shared/messages';
2-
import { Injectable } from '@angular/core';
3-
import { ofType, Actions, Effect } from '@ngrx/effects';
4-
import { Action } from '@ngrx/store';
5-
import { of, Observable } from 'rxjs';
6-
import { ToastrService } from 'ngx-toastr';
7-
import { catchError, map, mergeMap } from 'rxjs/operators';
8-
import { EntryService } from '../services/entry.service';
1+
import {INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY} from './../../shared/messages';
2+
import {Injectable} from '@angular/core';
3+
import {ofType, Actions, Effect} from '@ngrx/effects';
4+
import {Action} from '@ngrx/store';
5+
import {of, Observable} from 'rxjs';
6+
import {ToastrService} from 'ngx-toastr';
7+
import {catchError, map, mergeMap} from 'rxjs/operators';
8+
import {EntryService} from '../services/entry.service';
99
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) {
14+
}
1415

1516
@Effect()
1617
loadEntriesSummary$: Observable<Action> = this.actions$.pipe(
@@ -45,7 +46,7 @@ export class EntryEffects {
4546
} else {
4647
const endDate = new Date(activeEntry.start_date);
4748
endDate.setHours(23, 59, 59);
48-
return new actions.UpdateActiveEntry({ id: activeEntry.id, end_date: endDate.toISOString() });
49+
return new actions.UpdateActiveEntry({id: activeEntry.id, end_date: endDate.toISOString()});
4950
}
5051
}
5152
}),
@@ -118,9 +119,7 @@ export class EntryEffects {
118119
mergeMap((entry) =>
119120
this.entryService.updateActiveEntry(entry).pipe(
120121
map((entryResponse) => {
121-
if (entryResponse.end_date && entry.start_date === null) {
122-
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
123-
}
122+
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
124123
return new actions.UpdateActiveEntrySuccess(entryResponse);
125124
}),
126125
catchError((error) => {

0 commit comments

Comments
 (0)