import { OptionalNullable } from '@humand-packages/common';
import { DaySummaryScheduleSource } from '../../types/scheduleSource';
import { TimeTrackingDaySummaryHours } from '../daySummaryHours';
import { TimeTrackingDaySummaryScheduleDataForShiftCalendar } from '../daySummarySchedule';
import { TimeSlot } from '../timeTracking/scheduleData';
import { TimeTrackingDaySummaryHoliday } from '../timeTrackingDaySummaryHoliday';
import { TimeTrackingDaySummaryTimeOff } from '../timeTrackingDaySummaryTimeOff';
import { ShiftWithAssignedData } from './shift';

export class ShiftCalendar {
    constructor(properties: OptionalNullable<ShiftCalendar>) {
        this.count = properties.count;
        this.total = properties.total;
        this.items = properties.items;
        this.limit = properties.limit;
        this.page = properties.page;
        this.totalPages = properties.totalPages;
    }

    count: number;
    total: number;
    items: ShiftCalendarUser[];
    limit: number;
    page: number;
    totalPages: number;
}

export class ShiftCalendarUser {
    constructor(properties: OptionalNullable<ShiftCalendarUser>) {
        this.userId = properties.userId;
        this.employeeInternalId = properties.employeeInternalId;
        this.fullName = properties.fullName;
        this.profilePicture = properties.profilePicture ?? null;
        this.days = properties.days;
        this.shiftScheduleHours = properties.shiftScheduleHours;
    }

    userId: number;
    employeeInternalId: string;
    fullName: string;
    profilePicture: string | null;
    days: Record<string, ShiftCalendarDay>;
    shiftScheduleHours: ShiftScheduledHours;
}

export class ShiftCalendarDay {
    constructor(properties: OptionalNullable<ShiftCalendarDay>) {
        this.daySummaryHours = properties.daySummaryHours;
        this.scheduledData = properties.scheduledData;
        this.shiftScheduledHours = properties.shiftScheduledHours;
        this.shifts = properties.shifts;
        this.timeOffs = properties.timeOffs;
        this.holidays = properties.holidays;
    }

    daySummaryHours: TimeTrackingDaySummaryHours;
    scheduledData: TimeTrackingDaySummaryScheduleDataForShiftCalendar;
    shiftScheduledHours: ShiftScheduledHours;
    shifts: ShiftWithAssignedData[];
    timeOffs?: TimeTrackingDaySummaryTimeOff[];
    holidays?: TimeTrackingDaySummaryHoliday[];
}

export class ShiftScheduledHours {
    constructor(properties: OptionalNullable<ShiftScheduledHours>) {
        this.published = properties.published;
        this.draft = properties.draft;
        this.total = properties.total;
    }

    published: number;
    draft: number;
    total: number;
}

export class ShiftMyCalendarDay {
    constructor(properties: OptionalNullable<ShiftMyCalendarDay>) {
        this.holidays = properties.holidays;
        this.timeOffs = properties.timeOffs;
        this.isWorkday = properties.isWorkday;
        this.scheduleData = properties.scheduleData;
    }

    holidays: TimeTrackingDaySummaryHoliday[];
    timeOffs: TimeTrackingDaySummaryTimeOff[];
    isWorkday: boolean;
    scheduleData: TimeTrackingShiftMyCalendarScheduleData;
}

export class TimeTrackingShiftMyCalendarScheduleData {
    constructor(properties: OptionalNullable<TimeTrackingShiftMyCalendarScheduleData>) {
        this.source = properties.source;
        this.timeSlots = properties.timeSlots;
        this.shiftAssociations = properties.shiftAssociations;
    }

    source: DaySummaryScheduleSource;
    timeSlots?: TimeSlot[];
    shiftAssociations?: ShiftAssociation[];
}

export class ShiftAssociation {
    constructor(properties: OptionalNullable<ShiftAssociation>) {
        this.id = properties.id;
        this.name = properties.name ?? null;
        this.description = properties.description ?? null;
        this.timeSlots = properties.timeSlots;
        this.isFromShiftRotation = properties.isFromShiftRotation;
    }

    id: number;
    name: string | null;
    description: string | null;
    timeSlots: TimeSlot[];
    isFromShiftRotation: boolean;
}

export class ShiftMyCalendar {
    constructor(properties: OptionalNullable<ShiftMyCalendar>) {
        this.days = properties.days;
    }

    days: Record<string, ShiftMyCalendarDay>;
}
