Skip to content

Commit 4a80387

Browse files
committed
feat: preload data of last entry on switching project #503
1 parent 94c8360 commit 4a80387

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
<strong><span [innerHTML]="item.name"></span></strong>
2727
</div>
2828
<div class="p-2 pr-3">
29-
<button *ngIf="showClockIn" class="btn btn-sm btn-primary btn-select" (click)="clockIn(item.id, item.customer_name, item.name)">Clock In</button>
29+
<button *ngIf="showClockIn" class="btn btn-sm btn-primary btn-select"
30+
(click)="clockIn(item.id, item.customer_name, item.name)">Clock In</button>
3031
<button *ngIf="!showClockIn" class="btn btn-sm btn-primary btn-select"
3132
(click)="switch(item.id, item.customer_name, item.name)">Switch</button>&nbsp;
32-
<button *ngIf="!showClockIn" class="btn btn-sm btn-update btn-select" (click)="updateProject(item.id)">Update
33-
project</button>
33+
<button *ngIf="!showClockIn" class="btn btn-sm btn-update btn-select"
34+
(click)="updateProject(item.id)">Update project</button>
3435
</div>
3536
</div>
3637
</ng-template>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ describe('TimeEntryActionEffects', () => {
5151
});
5252
});
5353

54-
it('stop the active entry and return a CreateEntryAction', (done) => {
54+
it('stop the active entry and return a ClockInAction', (done) => {
5555
actions$ = of(new SwitchTimeEntry('entry-id', 'project-id'));
5656
spyOn(service, 'stopEntryRunning').and.returnValue(of({ end_date: new Date() }));
57-
spyOn(service, 'createEntry').and.returnValue(of({}));
5857

5958
effects.switchEntryRunning$.subscribe(action => {
6059
expect(service.stopEntryRunning).toHaveBeenCalledWith('entry-id');
61-
expect(action.type).toBe(EntryActionTypes.CREATE_ENTRY);
60+
expect(action.type).toBe(EntryActionTypes.CLOCK_IN);
6261
done();
6362
});
6463
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ export class EntryEffects {
2121
map((response) => {
2222
const stopDateForEntry = new Date(response.end_date);
2323
stopDateForEntry.setSeconds(stopDateForEntry.getSeconds() + 1);
24-
return new actions.CreateEntry({
24+
const entry = {
2525
project_id: action.idProjectSwitching,
2626
start_date: stopDateForEntry.toISOString(),
2727
timezone_offset: new Date().getTimezoneOffset(),
28-
});
28+
};
29+
return new actions.ClockIn(entry);
2930
}),
3031
catchError((error) => {
3132
this.toastrService.warning('We could not perform this operation, try again later');

0 commit comments

Comments
 (0)