Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: #333 Enabling toastr messages when updating time entries
  • Loading branch information
Juan Gabriel Guzman committed Jun 11, 2020
commit 1b0e5488ca7e844082f5499e6d89a5c919eca4cb
25 changes: 12 additions & 13 deletions src/app/modules/time-clock/store/entry.effects.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from './../../shared/messages';
import { Injectable } from '@angular/core';
import { ofType, Actions, Effect } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { of, Observable } from 'rxjs';
import { ToastrService } from 'ngx-toastr';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { EntryService } from '../services/entry.service';
import {INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY} from './../../shared/messages';
import {Injectable} from '@angular/core';
import {ofType, Actions, Effect} from '@ngrx/effects';
import {Action} from '@ngrx/store';
import {of, Observable} from 'rxjs';
import {ToastrService} from 'ngx-toastr';
import {catchError, map, mergeMap} from 'rxjs/operators';
import {EntryService} from '../services/entry.service';
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<Action> = this.actions$.pipe(
Expand Down Expand Up @@ -45,7 +46,7 @@ export class EntryEffects {
} else {
const endDate = new Date(activeEntry.start_date);
endDate.setHours(23, 59, 59);
return new actions.UpdateActiveEntry({ id: activeEntry.id, end_date: endDate.toISOString() });
return new actions.UpdateActiveEntry({id: activeEntry.id, end_date: endDate.toISOString()});
}
}
}),
Expand Down Expand Up @@ -118,9 +119,7 @@ export class EntryEffects {
mergeMap((entry) =>
this.entryService.updateActiveEntry(entry).pipe(
map((entryResponse) => {
if (entryResponse.end_date && entry.start_date === null) {
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
}
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
return new actions.UpdateActiveEntrySuccess(entryResponse);
}),
catchError((error) => {
Expand Down