57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
export type Weekday = 'SUN' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT';
|
|
|
|
export const WEEKDAYS: Weekday[] = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
|
|
|
|
export class SchedulePreset {
|
|
id: number;
|
|
name: string;
|
|
is_default: boolean;
|
|
shifts: SchedulePresetShift[];
|
|
|
|
constructor() {
|
|
this.id = -1;
|
|
this.name = 'default';
|
|
this.is_default = true;
|
|
this.shifts = [];
|
|
}
|
|
}
|
|
|
|
class SchedulePresetShift {
|
|
preset_id: number;
|
|
week_day: Weekday;
|
|
type: string;
|
|
start_time: string;
|
|
end_time: string;
|
|
is_remote: boolean;
|
|
|
|
constructor(weekday: Weekday) {
|
|
this.preset_id = -1;
|
|
this.week_day = weekday;
|
|
this.type = '';
|
|
this.start_time = '00:00';
|
|
this.end_time = '00:00';
|
|
this.is_remote = false;
|
|
}
|
|
}
|
|
|
|
export class SchedulePresetFrontend {
|
|
id: number;
|
|
name: string;
|
|
is_default: boolean;
|
|
weekdays: WeekdayPresetShifts[];
|
|
|
|
constructor(schedule_preset?: SchedulePreset) {
|
|
this.id = schedule_preset?.id ?? -1;
|
|
this.name = schedule_preset?.name ?? '';
|
|
this.is_default = schedule_preset?.is_default ?? false;
|
|
this.weekdays = WEEKDAYS.map(day => ({
|
|
day,
|
|
shifts: schedule_preset !== undefined ? schedule_preset?.shifts.filter(shift => shift.week_day === day) : [],
|
|
}))
|
|
}
|
|
}
|
|
|
|
export interface WeekdayPresetShifts {
|
|
day: Weekday;
|
|
shifts: SchedulePresetShift[];
|
|
} |