import { Expose, Type } from 'class-transformer';
import { ArrayMinSize, IsArray, IsBoolean, IsDateString, IsDefined, IsIn, IsNumber, IsOptional, Min, ValidateNested } from 'class-validator';
import { TimeTrackingEntrySource } from '../../business/types/source';
import { BaseTimeTrackingEntryRequestsVC } from './baseTimeTrackingEntryRequestsVC';

export class UpdateTimeTrackingEntryRequestVC extends BaseTimeTrackingEntryRequestsVC {
    @IsDefined()
    @IsNumber()
    @Min(1)
    @Expose()
    userId!: number;

    @IsDefined()
    @IsDateString()
    @Expose()
    time!: Date;

    @IsDefined()
    @IsNumber()
    @Min(1)
    @Expose()
    summaryId!: number;

    @IsDefined()
    @IsIn(Object.values(TimeTrackingEntrySource))
    @Expose()
    source!: TimeTrackingEntrySource;

    @IsOptional()
    @IsNumber()
    @Min(1)
    @Expose()
    id?: number;

    @Expose()
    @IsOptional()
    @IsBoolean()
    isRemoteWork?: boolean;
}

export class UpdateTimeTrackingEntryRequestsVC {
    @IsArray()
    @IsDefined()
    @ArrayMinSize(0)
    @ValidateNested({ each: true })
    @Type(() => UpdateTimeTrackingEntryRequestVC)
    @Expose()
    entries!: UpdateTimeTrackingEntryRequestVC[];

    @IsDefined()
    @IsNumber()
    @Min(1)
    @Expose()
    summaryId!: number;
}
