import { ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsOptional,
  IsArray,
  IsNumber,
  Min,
  IsEnum,
  IsBoolean,
  IsDateString,
  IsString,
} from 'class-validator';

export class RateSearchFiltersDto {
  @ApiPropertyOptional({
    description: 'List of company names to include',
    type: [String],
    example: ['SSC Consolidation', 'ECU Worldwide'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  companies?: string[];

  @ApiPropertyOptional({
    description: 'Only show "Direct" routing (exclude transhipment)',
    example: false,
  })
  @IsOptional()
  @IsBoolean()
  onlyDirect?: boolean;

  @ApiPropertyOptional({
    description: 'Exclude routes where DG is not accepted',
    example: false,
  })
  @IsOptional()
  @IsBoolean()
  excludeNonDgRoutes?: boolean;

  @ApiPropertyOptional({
    description: 'Minimum price (totalPriceForSorting)',
    minimum: 0,
    example: 500,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minPrice?: number;

  @ApiPropertyOptional({
    description: 'Maximum price (totalPriceForSorting)',
    minimum: 0,
    example: 3000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxPrice?: number;

  @ApiPropertyOptional({
    description: 'Minimum transit time in days',
    minimum: 0,
    example: 20,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minTransitDays?: number;

  @ApiPropertyOptional({
    description: 'Maximum transit time in days',
    minimum: 0,
    example: 45,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxTransitDays?: number;

  @ApiPropertyOptional({
    description: 'Container types to filter by',
    type: [String],
    example: ['LCL'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  containerTypes?: string[];

  @ApiPropertyOptional({
    description: 'Preferred currency for price display',
    enum: ['USD', 'EUR'],
    example: 'USD',
  })
  @IsOptional()
  @IsEnum(['USD', 'EUR'])
  currency?: 'USD' | 'EUR';

  @ApiPropertyOptional({
    description: 'Departure date to check rate validity (ISO 8601)',
    example: '2026-06-15',
  })
  @IsOptional()
  @IsDateString()
  departureDate?: string;
}
