[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;
};
export const emptyJob: EditableJob = {
start: new Date(),
end: date.addToDate(new Date(), { hours: 1 }),
services: [],
required_services: 2,
};
export const emptyJob = (d: Date | number = new Date()): EditableJob =>
Object.assign(
{},
{
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 = {
start: new Date(),
jobs: [Object.assign({}, emptyJob)],
is_template: false,
};
export const emptyEvent = (d: Date | number = new Date()): EditableEvent =>
Object.assign(
{},
{
start: date.adjustDate(d, { hours: 0, minutes: 0, seconds: 0 }),
jobs: [],
is_template: false,
}
);