import { YardCountry } from '@edr/types';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsInt, IsOptional, IsUUID, MaxLength, Min, IsString } from 'class-validator';

export class CreateYardDto {
  @ApiProperty({ description: 'Customer-facing yard label', maxLength: 100 })
  @IsString()
  @MaxLength(100)
  label!: string;

  @ApiProperty({ enum: YardCountry, description: 'Country where the yard is located' })
  @IsEnum(YardCountry)
  country!: YardCountry;

  @ApiPropertyOptional({ default: true })
  @IsOptional()
  @IsBoolean()
  isActive?: boolean;

  @ApiPropertyOptional({
    default: false,
    description:
      'This yard can load/unload cargo. Intercity bookings may only be loaded at their origin and unloaded at their destination when it is a facility.',
  })
  @IsOptional()
  @IsBoolean()
  hasFacility?: boolean;

  @ApiPropertyOptional({ default: 1, description: 'UI display sort order' })
  @IsOptional()
  @IsInt()
  @Min(1)
  displayOrder?: number;

  @ApiPropertyOptional({ description: 'Insert after this record ID' })
  @IsOptional()
  @IsUUID('4')
  insertAfterId?: string;
}
