[events] Create empty models from factory function (fresh objects)

This commit is contained in:
Ferdinand Thiessen 2021-04-04 21:35:42 +02:00
parent 7d1993e3fa
commit 5780c73608
1 changed files with 19 additions and 11 deletions

View File

@ -13,15 +13,23 @@ export type EditableJob = Omit<Omit<FG.Job, 'type'>, 'id'> & {
id?: number; id?: number;
}; };
export const emptyJob: EditableJob = { export const emptyJob = (d: Date | number = new Date()): EditableJob =>
start: new Date(), Object.assign(
end: date.addToDate(new Date(), { hours: 1 }), {},
services: [], {
required_services: 2, start: date.adjustDate(d, { minutes: 0, seconds: 0 }),
}; end: date.addToDate(date.adjustDate(d, { minutes: 0, seconds: 0 }), { hours: 1 }),
services: [],
required_services: 2,
}
);
export const emptyEvent: EditableEvent = { export const emptyEvent = (d: Date | number = new Date()): EditableEvent =>
start: new Date(), Object.assign(
jobs: [Object.assign({}, emptyJob)], {},
is_template: false, {
}; start: date.adjustDate(d, { hours: 0, minutes: 0, seconds: 0 }),
jobs: [],
is_template: false,
}
);