Skip to content

Commit 18f8c91

Browse files
committed
fix: ioet#242 remove update notification from time-clock
1 parent 1327db7 commit 18f8c91

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY, UNEXPECTED_ERROR } from './../../shared/messages';
2+
import { Entry } from './../../shared/models/entry.model';
13
import { Injectable } from '@angular/core';
24
import { ofType, Actions, Effect } from '@ngrx/effects';
35
import { Action } from '@ngrx/store';
@@ -55,11 +57,14 @@ export class EntryEffects {
5557
mergeMap((entry) =>
5658
this.entryService.createEntry(entry).pipe(
5759
map((entryData) => {
58-
this.toastrService.success('Entry was saved successfully');
60+
if (entryData.end_date !== null) {
61+
this.toastrService.success(INFO_SAVED_SUCCESSFULLY);
62+
}
5963
return new actions.CreateEntrySuccess(entryData);
6064
}),
6165
catchError((error) => {
62-
this.toastrService.error(error.error.message);
66+
console.error(error);
67+
this.toastrService.success(UNEXPECTED_ERROR);
6368
return of(new actions.CreateEntryFail(error.error.message));
6469
})
6570
)
@@ -72,8 +77,15 @@ export class EntryEffects {
7277
map((action: actions.DeleteEntry) => action.entryId),
7378
mergeMap((entryId) =>
7479
this.entryService.deleteEntry(entryId).pipe(
75-
map(() => new actions.DeleteEntrySuccess(entryId)),
76-
catchError((error) => of(new actions.DeleteEntryFail(error)))
80+
map(() => {
81+
this.toastrService.success(INFO_DELETE_SUCCESSFULLY);
82+
return new actions.DeleteEntrySuccess(entryId);
83+
}),
84+
catchError((error) => {
85+
console.log(error);
86+
this.toastrService.success(UNEXPECTED_ERROR);
87+
return of(new actions.DeleteEntryFail(error));
88+
})
7789
)
7890
)
7991
);
@@ -85,11 +97,11 @@ export class EntryEffects {
8597
mergeMap((project) =>
8698
this.entryService.updateActiveEntry(project).pipe(
8799
map((projectData) => {
88-
this.toastrService.success('Entry was updated successfully');
89100
return new actions.UpdateActiveEntrySuccess(projectData);
90101
}),
91102
catchError((error) => {
92-
this.toastrService.error(error.error.message);
103+
console.log(error);
104+
this.toastrService.success(UNEXPECTED_ERROR);
93105
return of(new actions.UpdateActiveEntryFail(error));
94106
})
95107
)
@@ -103,6 +115,7 @@ export class EntryEffects {
103115
mergeMap((timeEntryId) =>
104116
this.entryService.stopEntryRunning(timeEntryId).pipe(
105117
map(() => {
118+
this.toastrService.success('You clocked-out successfully');
106119
return new actions.StopTimeEntryRunningSuccess(timeEntryId);
107120
}),
108121
catchError((error) => of(new actions.StopTimeEntryRunningFail(error.error.message)))

0 commit comments

Comments
 (0)