import { WORKDAYS } from '@humand-packages/common';
import { User } from '../../../users/business/models/user';
import { BulkUploadFileTranslationKeys } from '../../presentation/constants/bulkUpload';
import { WorkScheduleUserAssignmentType } from '../types/workScheduleUserAssignment';
import { TimeSlot } from './timeTracking/scheduleData';

export class ScheduledDays {
    dayOfWeek!: WORKDAYS;
    timeSlots!: TimeSlot[];
}

export class WorkScheduleCreationParameters {
    name!: string;
    description!: string;
    hash?: string;
    instanceId!: number;
    scheduledDays!: ScheduledDays[];
    generalTimeSlots?: TimeSlot[];
    createdBy!: number;
    autoCreated?: boolean;
}

export class WorkScheduleUpdateAttributes {
    name?: string;
    description?: string;
    scheduledDays?: ScheduledDays[];
    generalTimeSlots?: TimeSlot[];
}

export class WorkScheduleSimpleUpdateAttributes {
    name?: string;
    description?: string;
}

export class WorkScheduleCreationAttributes extends WorkScheduleCreationParameters {
    code!: string;
    version!: number;
}

export class WorkSchedule extends WorkScheduleCreationAttributes {
    id!: number;
    collaborators!: number[];
    //Audits
    deletedAt?: Date;
    createdAt!: Date;
    updatedAt!: Date;
    lastVersion!: boolean;
}

export class AssignedWorkSchedule extends WorkSchedule {
    startDate!: string;
    endDate!: string;
    current!: boolean;
    userId!: number;
}

export class WorkScheduleUserAssignment {
    id!: number;
    workScheduleId!: number;
    startDate!: Date;
    endDate?: Date;
    endDateString?: string;
    startDateString!: string;
    current!: boolean;
    userId!: number;
    user?: User;
    assignmentTypeNumber!: number;
    assignmentType?: WorkScheduleUserAssignmentType;
    workScheduleVersion!: number;
}

export const workScheduleMandatoryUpdateTranslationKeys = [BulkUploadFileTranslationKeys.EMPLOYEE_INTERNAL_ID];

export const generalWorkScheduleTranslationKeys = [
    BulkUploadFileTranslationKeys.MONDAY,
    BulkUploadFileTranslationKeys.TUESDAY,
    BulkUploadFileTranslationKeys.WEDNESDAY,
    BulkUploadFileTranslationKeys.THURSDAY,
    BulkUploadFileTranslationKeys.FRIDAY,
    BulkUploadFileTranslationKeys.SATURDAY,
    BulkUploadFileTranslationKeys.SUNDAY,
];

export const allWorkScheduleTranslationKeys = [...workScheduleMandatoryUpdateTranslationKeys, ...generalWorkScheduleTranslationKeys];

export class WorkScheduleUser {
    id!: number;
    workScheduleId!: number;
    startDate!: Date;
    endDate?: Date;
    startDateString!: string;
    endDateString!: string;
    current!: boolean;
    userId!: number;
}
