import { OptionalNullable } from '@humand-packages/common';
import { ShiftRotationDayType } from '../../enum/shiftManagement/shiftRotationDayType';

export class ShiftRotationDayShiftForCreation {
    constructor(properties: OptionalNullable<ShiftRotationDayShiftForCreation>) {
        this.instanceId = properties.instanceId;
        this.shiftCode = properties.shiftCode;
    }

    readonly instanceId: number;
    public shiftCode: string;
}

export class ShiftRotationDayShift extends ShiftRotationDayShiftForCreation {
    constructor(properties: OptionalNullable<ShiftRotationDayShift>) {
        super(properties);
        this.id = properties.id;
        this.shiftRotationDayId = properties.shiftRotationDayId;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
    }

    readonly id: string;
    readonly shiftRotationDayId: string;
    readonly createdAt: Date;
    readonly updatedAt: Date;
}

export class ShiftRotationDayForCreation {
    constructor(properties: OptionalNullable<ShiftRotationDayForCreation>) {
        this.instanceId = properties.instanceId;
        this.dayPosition = properties.dayPosition;
        this.type = properties.type;
        this.shifts = properties.shifts;
    }

    readonly instanceId: number;
    public dayPosition: number;
    public type: ShiftRotationDayType;
    public shifts: ShiftRotationDayShiftForCreation[];
}

export class ShiftRotationDay extends ShiftRotationDayForCreation {
    constructor(properties: OptionalNullable<ShiftRotationDay> & { shifts: ShiftRotationDayShift[] }) {
        super(properties);
        this.id = properties.id;
        this.shiftRotationId = properties.shiftRotationId;
        this.shifts = properties.shifts;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
    }

    readonly id: string;
    readonly shiftRotationId: string;
    public shifts: ShiftRotationDayShift[];
    readonly createdAt: Date;
    readonly updatedAt: Date;
}

export class ShiftRotationForCreation {
    constructor(properties: OptionalNullable<ShiftRotationForCreation>) {
        this.instanceId = properties.instanceId;
        this.name = properties.name;
        this.description = properties.description ?? null;
        this.days = properties.days;
    }

    readonly instanceId: number;
    public name: string;
    public description: string | null;
    public days: ShiftRotationDayForCreation[];
}

export class ShiftRotation extends ShiftRotationForCreation {
    constructor(properties: OptionalNullable<ShiftRotation> & { days: ShiftRotationDay[] }) {
        super(properties);
        this.id = properties.id;
        this.days = properties.days;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
        this.deletedAt = properties.deletedAt ?? null;
    }

    readonly id: string;
    public days: ShiftRotationDay[];
    readonly createdAt: Date;
    readonly updatedAt: Date;
    public deletedAt: Date | null;
}

export interface ShiftRotationAggregates {
    cycleLength: number;
    workDaysCount: number;
    restDaysCount: number;
    totalHours: number;
}

export class ShiftRotationListItem {
    constructor(properties: OptionalNullable<ShiftRotationListItem>) {
        this.id = properties.id;
        this.name = properties.name;
        this.description = properties.description ?? null;
        this.cycleLength = properties.cycleLength;
        this.workDaysCount = properties.workDaysCount;
        this.restDaysCount = properties.restDaysCount;
        this.totalHours = properties.totalHours;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
    }

    readonly id: string;
    readonly name: string;
    readonly description: string | null;
    readonly cycleLength: number;
    readonly workDaysCount: number;
    readonly restDaysCount: number;
    readonly totalHours: number;
    readonly createdAt: Date;
    readonly updatedAt: Date;
}
