import {
  IsString,
  IsInt,
  IsOptional,
  IsBoolean,
  MaxLength,
  Min,
  Max,
  IsIn,
  ValidateIf,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateProjectDto {
  @ApiProperty({ example: 3, required: false })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(12)
  fromMonth?: number;

  @ApiProperty({ example: 2023, required: false })
  @IsOptional()
  @IsInt()
  @Min(1970)
  @Max(2100)
  fromYear?: number;

  @ApiProperty({ example: 6, required: false })
  @IsOptional()
  @ValidateIf((o: UpdateProjectDto) => !o.isCurrent)
  @IsInt()
  @Min(1)
  @Max(12)
  toMonth?: number;

  @ApiProperty({ example: 2024, required: false })
  @IsOptional()
  @ValidateIf((o: UpdateProjectDto) => !o.isCurrent)
  @IsInt()
  @Min(1970)
  @Max(2100)
  toYear?: number;

  @ApiProperty({ example: false, required: false })
  @IsOptional()
  @IsBoolean()
  isCurrent?: boolean;

  @ApiProperty({ example: 'Senior DevOps Engineer', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  role?: string;

  @ApiProperty({ example: 'Aufbau der K8s-Infrastruktur', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(1500, { message: 'Aufgaben dürfen maximal 1500 Zeichen lang sein' })
  tasks?: string;

  @ApiProperty({ example: 'Xinion GmbH', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  company?: string;

  @ApiProperty({ example: '51-200', required: false })
  @IsOptional()
  @IsString()
  @IsIn(['1-10', '11-50', '51-200', '201-500', '501-1000', '1001-5000', '5000+'])
  companySize?: string;

  @ApiProperty({ example: 'IT-Dienstleistung', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  industry?: string;
}
