diff --git a/src/app/modules/time-clock/pages/time-clock.component.html b/src/app/modules/time-clock/pages/time-clock.component.html index d8f11b4d4..ae04628e4 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.html +++ b/src/app/modules/time-clock/pages/time-clock.component.html @@ -36,9 +36,11 @@
Projects

- +
- +
@@ -61,12 +63,7 @@
Projects
-
diff --git a/src/app/modules/time-clock/pages/time-clock.component.spec.ts b/src/app/modules/time-clock/pages/time-clock.component.spec.ts index 87fb266b1..9e1cdae71 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.spec.ts +++ b/src/app/modules/time-clock/pages/time-clock.component.spec.ts @@ -1,3 +1,4 @@ +import { LoadActivities } from '../../activities-management/store/activity-management.actions'; import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; @@ -49,6 +50,14 @@ describe('TimeClockComponent', () => { expect(component).toBeTruthy(); }); + it('onInit, LoadActivities action is dispatched', () => { + spyOn(store, 'dispatch'); + + component.ngOnInit(); + + expect(store.dispatch).toHaveBeenCalledWith(new LoadActivities()); + }); + it('Service injected via inject(...) and TestBed.get(...) should be the same instance', inject( [ProjectService], (injectService: ProjectService) => { diff --git a/src/app/modules/time-clock/pages/time-clock.component.ts b/src/app/modules/time-clock/pages/time-clock.component.ts index e255c054c..8cfab20de 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.ts +++ b/src/app/modules/time-clock/pages/time-clock.component.ts @@ -1,4 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { Store, select } from '@ngrx/store'; + +import { LoadActivities, ActivityState, allActivities } from '../../activities-management/store/'; +import { Activity } from 'src/app/modules/shared/models'; + @Component({ selector: 'app-time-clock', @@ -25,7 +30,9 @@ export class TimeClockComponent implements OnInit { isClockInEnable = false; isHidenForm = true; - constructor() { + activities: Activity[] = []; + + constructor(private store: Store) { this.isClockIn = true; this.isEnterTechnology = false; this.hourCounterRealTime = 0; @@ -36,6 +43,14 @@ export class TimeClockComponent implements OnInit { this.seconds = 0; } + ngOnInit() { + this.store.dispatch(new LoadActivities()); + const activities$ = this.store.pipe(select(allActivities)); + activities$.subscribe((response) => { + this.activities = response; + }); + } + employeClockIn(): boolean { this.isClockInEnable = true; this.isClockIn = !this.isClockIn; @@ -119,5 +134,4 @@ export class TimeClockComponent implements OnInit { this.isClockInEnable = false; } - ngOnInit(): void {} }