import { ISO_DATE, OptionalNumbersArrayOrStringToNumbersArray, OptionalStringToStringsArray } from '@humand-packages/common';
import { Expose } from 'class-transformer';
import { IsArray, IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
import { IsValidDate } from '../../../../../middlewares/dateValidator';
import { TimeTrackingCategorizedHourStatus } from '../../../infrastructure/constants/timeTracking/categorizedHourStatus';
import { IsStartDateBeforeEndDate } from '../../validators/isStartDateBeforeEndDate/isStartDateBeforeEndDate';

export class CategorizedHoursFiltersVC {
    @IsOptional()
    @IsString()
    @Expose()
    search?: string;

    @IsOptional()
    @OptionalStringToStringsArray()
    @IsArray()
    @IsEnum(TimeTrackingCategorizedHourStatus, { each: true })
    @Expose()
    status?: TimeTrackingCategorizedHourStatus[];

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

    @IsOptional()
    @IsValidDate(ISO_DATE)
    @Expose()
    endDate?: string;

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

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

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

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