import { Freight } from '@edr/types';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsEnum, IsIn, IsOptional, IsUUID } from 'class-validator';

import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';

export class ListBuiltTrainsQueryDto extends PaginationQueryDto {
  @ApiPropertyOptional({ enum: Freight.TrainStatus })
  @IsOptional()
  @IsEnum(Freight.TrainStatus)
  status?: Freight.TrainStatus;

  @ApiPropertyOptional({ format: 'uuid', description: 'Only trains sitting in this yard' })
  @IsOptional()
  @IsUUID()
  currentYardId?: string;

  @ApiPropertyOptional({ enum: ['code', 'trainName', 'status', 'createdAt'] })
  @IsOptional()
  @IsIn(['code', 'trainName', 'status', 'createdAt'])
  sortBy?: 'code' | 'trainName' | 'status' | 'createdAt';
}
