Skip to content

Commit 1729f78

Browse files
author
Juan Gabriel Guzman
committed
feat: #333 Refreshing data when creating/updting time entries
1 parent 36d0fcf commit 1729f78

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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_DELETE_SUCCESSFULLY, INFO_SAVED_SUCCESSFULLY } from './../../shared/messages';
2+
import { Injectable } from '@angular/core';
3+
import { Actions, Effect, ofType } from '@ngrx/effects';
4+
import { Action } from '@ngrx/store';
5+
import { Observable, of } 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()

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,17 @@ describe('TimeEntriesComponent', () => {
249249

250250
expect(component.doSave).toHaveBeenCalledWith(entryToSave);
251251
}));
252+
253+
it('when saving time entries, the time entries should be queried', () => {
254+
const currentMonth = new Date().getMonth() + 1;
255+
const entryToSave = {
256+
project_id: 'project-id'
257+
};
258+
component.activeTimeEntry = null;
259+
spyOn(store, 'dispatch');
260+
261+
component.saveEntry(entryToSave);
262+
263+
expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntries(currentMonth));
264+
});
252265
});

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class TimeEntriesComponent implements OnInit {
6565
} else {
6666
this.store.dispatch(new entryActions.CreateEntry(entry));
6767
}
68+
this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1));
6869
}
6970

7071
removeEntry(entryId: string) {

0 commit comments

Comments
 (0)