Skip to content

Commit

Permalink
Merge pull request #105 from FrontMen/fix/delete-copied-timesheet
Browse files Browse the repository at this point in the history
fix(records): delete ids on copy timesheet
  • Loading branch information
sanderdejong88 authored Jun 7, 2021
2 parents 69d1edf + 44438b6 commit a404e81
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions composables/useTimesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,32 @@ export default (employeeId: string, startTimestamp?: number) => {
};

const copyPreviousWeek = () => {
const startDate = new Date(recordsState.value.selectedWeek[0].date);
const startDate = new Date(
getDayOnGMT(recordsState.value.selectedWeek[0].date)
);
const prevStartDate = subDays(startDate, 7);
const previousWeek = buildWeek(startOfISOWeek(prevStartDate), []);

timesheet.value = createWeeklyTimesheet({
const previousWeekTimesheet = createWeeklyTimesheet({
week: previousWeek,
timeRecords: recordsState.value.timeRecords,
travelRecords: recordsState.value.travelRecords,
workScheme: recordsState.value.workScheme,
});

const newTimesheet = {
projects: previousWeekTimesheet.projects.map((project) => ({
...project,
ids: new Array(7).fill(null),
})),
travelProject: {
...previousWeekTimesheet.travelProject!,
ids: new Array(7).fill(null),
},
};

timesheet.value = newTimesheet;

hasUnsavedChanges.value = true;
};

Expand Down

0 comments on commit a404e81

Please sign in to comment.