import { ISO_DATE } from '@humand-packages/common';
import { Expose, Type } from 'class-transformer';
import { ArrayMinSize, IsArray, IsBoolean, IsDefined, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';
import { IsValidDate } from '../../../../../middlewares/dateValidator';
import { ShiftManagementCalendarFiltersVC } from './shiftManagementCalendarFiltersVC';

export class ShiftCopyVC {
    @IsDefined()
    @IsNumber()
    @Expose()
    sourceUserId!: number;

    @IsArray()
    @IsValidDate(ISO_DATE, { each: true })
    @Expose()
    dates?: string[];

    @IsArray()
    @IsNumber({}, { each: true })
    @Expose()
    assignedShiftIds?: number[];
}

export class ShiftPasteVC {
    @IsOptional()
    @IsBoolean()
    @Expose()
    allUsers?: boolean;

    @IsOptional()
    @IsString()
    @Expose()
    @IsValidDate(ISO_DATE)
    startDate?: string;

    @IsOptional()
    @IsArray()
    @IsNumber({}, { each: true })
    @Expose()
    excludeTargetUserIds?: number[];

    @IsOptional()
    @ValidateNested()
    @Type(() => ShiftManagementCalendarFiltersVC)
    @Expose()
    filters?: ShiftManagementCalendarFiltersVC;

    @IsOptional()
    @IsArray()
    @ValidateNested({ each: true })
    @Type(() => ShiftPasteUserVC)
    @Expose()
    @ArrayMinSize(1)
    users?: ShiftPasteUserVC[];
}

export class ShiftPasteUserVC {
    @IsDefined()
    @IsNumber()
    @Expose()
    targetUserId!: number;

    @IsDefined()
    @IsString()
    @Expose()
    @IsValidDate(ISO_DATE)
    startDate!: string;
}

export class ShiftCopyAndPasteVC {
    @IsDefined()
    @ValidateNested()
    @Type(() => ShiftCopyVC)
    @Expose()
    copy!: ShiftCopyVC;

    @IsDefined()
    @ValidateNested()
    @Type(() => ShiftPasteVC)
    @Expose()
    paste!: ShiftPasteVC;
}
