import { WagonStatus } from '@edr/types';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsInt, IsOptional, IsString, IsUUID, Max, Min } from 'class-validator';

export class ListWagonsQueryDto {
  @ApiPropertyOptional({ description: 'Search wagon number (partial match)' })
  @IsOptional()
  @IsString()
  search?: string;

  @ApiPropertyOptional({ enum: WagonStatus })
  @IsOptional()
  @IsEnum(WagonStatus)
  status?: WagonStatus;

  @ApiPropertyOptional({ description: 'Filter by current yard' })
  @IsOptional()
  @IsUUID()
  currentYardId?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsUUID()
  wagonTypeId?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsUUID()
  trainId?: string;

  @ApiPropertyOptional({ default: 'wagonNumber' })
  @IsOptional()
  @IsString()
  sortBy?: string;

  @ApiPropertyOptional({ enum: ['ASC', 'DESC'], default: 'ASC' })
  @IsOptional()
  @IsString()
  sortOrder?: 'ASC' | 'DESC';

  @ApiPropertyOptional({ minimum: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number;

  @ApiPropertyOptional({ minimum: 1, maximum: 500 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(500)
  limit?: number;
}
