Skip to content

Commit e6f4748

Browse files
authored
Merge pull request ioet#468 from ioet/464-add-timezone-offset-to-time-entry
🚧 Send timezone_offset when time_entries are being created/updated
2 parents 927eb32 + d922cbb commit e6f4748

File tree

7 files changed

+31
-4
lines changed

7 files changed

+31
-4
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ describe('DetailsFieldsComponent', () => {
207207
description: '',
208208
start_date: new Date('2020-02-05T00:00:01').toISOString(),
209209
end_date: new Date('2020-02-05T00:01:01').toISOString(),
210-
uri: ''
210+
uri: '',
211+
timezone_offset: new Date().getTimezoneOffset(),
211212
},
212213
shouldRestartEntry: false
213214
};
@@ -276,6 +277,7 @@ describe('DetailsFieldsComponent', () => {
276277
description: '',
277278
start_date: new Date('2020-06-11T00:00:10').toISOString(),
278279
uri: 'ticketUri',
280+
timezone_offset: new Date().getTimezoneOffset(),
279281
},
280282
shouldRestartEntry: false
281283
};

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
165165
start_date: new Date(`${entryDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(),
166166
end_date: new Date(`${entryDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(),
167167
uri: this.entryForm.value.uri,
168+
timezone_offset: new Date().getTimezoneOffset(),
168169
};
169170
if (this.goingToWorkOnThis) {
170171
delete entry.end_date;

src/app/modules/shared/models/entry.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export interface NewEntry {
1818
technologies?: string[];
1919
uri?: string;
2020
activity_id?: string;
21+
timezone_offset?: number;
2122
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,17 @@ describe('ProjectListHoverComponent', () => {
118118
expect(component.projectsForm.setValue)
119119
.toHaveBeenCalledWith({ project_id: 'customer - xyz'});
120120
});
121+
122+
it('creates time-entry with timezone_offset property', () => {
123+
spyOn(store, 'dispatch');
124+
component.clockIn('1', 'customer', 'project');
125+
expect(store.dispatch).toHaveBeenCalledWith(
126+
new CreateEntry({
127+
project_id: '1',
128+
start_date: new Date().toISOString(),
129+
timezone_offset: new Date().getTimezoneOffset()
130+
})
131+
);
132+
});
133+
121134
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
7878
}
7979

8080
clockIn(selectedProject, customerName, name) {
81-
const entry = { project_id: selectedProject, start_date: new Date().toISOString() };
81+
const entry = {
82+
project_id: selectedProject,
83+
start_date: new Date().toISOString(),
84+
timezone_offset: new Date().getTimezoneOffset(),
85+
};
8286
this.store.dispatch(new entryActions.CreateEntry(entry));
8387
this.projectsForm.setValue( { project_id: `${customerName} - ${name}`, } );
8488
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ 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({ project_id: action.idProjectSwitching, start_date: stopDateForEntry.toISOString() });
24+
return new actions.CreateEntry({
25+
project_id: action.idProjectSwitching,
26+
start_date: stopDateForEntry.toISOString(),
27+
timezone_offset: new Date().getTimezoneOffset(),
28+
});
2529
}),
2630
catchError((error) => {
2731
this.toastrService.warning(error.error.message);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ describe('TimeEntriesComponent', () => {
146146
entry: {
147147
project_id: 'project-id',
148148
end_date: '2010-05-05T10:04',
149-
start_date: null
149+
start_date: null,
150+
timezone_offset: 300,
150151
}, shouldRestartEntry: false
151152
};
152153
component.activeTimeEntry = null;
@@ -303,6 +304,7 @@ describe('TimeEntriesComponent', () => {
303304
description: 'description',
304305
technologies: [],
305306
uri: 'abc',
307+
timezone_offset: 300,
306308
}, shouldRestartEntry: false
307309
};
308310
component.entryId = undefined;

0 commit comments

Comments
 (0)