Skip to content
Merged
Show file tree
Hide file tree
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: 🚧 add timezone_offset to clockin/switch #464
  • Loading branch information
Angeluz-07 committed Jul 9, 2020
commit 28da5f917a34a669338d7fb6987b8cdae41da3c0
1 change: 1 addition & 0 deletions src/app/modules/shared/models/entry.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export interface NewEntry {
technologies?: string[];
uri?: string;
activity_id?: string;
timezone_offset: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
}

clockIn(selectedProject, customerName, name) {
const entry = { project_id: selectedProject, start_date: new Date().toISOString() };
const entry = {
project_id: selectedProject,
start_date: new Date().toISOString(),
timezone_offset: new Date().getTimezoneOffset(),
};
this.store.dispatch(new entryActions.CreateEntry(entry));
this.projectsForm.setValue( { project_id: `${customerName} - ${name}`, } );
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/modules/time-clock/store/entry.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export class EntryEffects {
map((response) => {
const stopDateForEntry = new Date(response.end_date);
stopDateForEntry.setSeconds(stopDateForEntry.getSeconds() + 1 );
return new actions.CreateEntry({ project_id: action.idProjectSwitching, start_date: stopDateForEntry.toISOString() });
return new actions.CreateEntry({
project_id: action.idProjectSwitching,
start_date: stopDateForEntry.toISOString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not your change, but it seems something is wrong here:
start_date: stopDateForEntry.toISOString(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to do with the logic of clocking out, when switching a project. The stopDate of the entry being clocked out is the startDate of the new time-entry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I get what you mean. In that case I would change line 23 to this:
const newTimeEntryStartDate = stopDateForEntry.setSeconds(stopDateForEntry.getSeconds() + 1 );
and line 26 to:
start_date: newTimeEntryStartDate.toISOString(),

In that way, it is easier to read.

timezone_offset: new Date().getTimezoneOffset(),
});
}),
catchError((error) => {
this.toastrService.warning(error.error.message);
Expand Down