import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
  IsOptional,
  IsString,
  IsNumber,
  IsBoolean,
  IsDate,
  Min,
} from 'class-validator';

export class CatalogFiltersDto {
  @ApiProperty({ required: false, description: 'Search by yacht name' })
  @IsOptional()
  @IsString()
  search?: string;

  @ApiProperty({
    required: false,
    description: 'Minimum length in meters',
    example: 10,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  minLength?: number;

  @ApiProperty({
    required: false,
    description: 'Maximum length in meters',
    example: 20,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  maxLength?: number;

  @ApiProperty({
    required: false,
    description: 'Minimum price',
    example: 30000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  minPrice?: number;

  @ApiProperty({
    required: false,
    description: 'Maximum price',
    example: 100000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  maxPrice?: number;

  @ApiProperty({
    required: false,
    description: 'Sort by price',
    example: 100000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  sortByPrice?: string;

  @ApiProperty({ required: false, description: 'Minimum year', example: 2019 })
  @IsOptional()
  @IsNumber()
  @Min(1900)
  @Type(() => Number)
  minYear?: number;

  @ApiProperty({ required: false, description: 'Maximum year', example: 2023 })
  @IsOptional()
  @IsNumber()
  @Min(1900)
  @Type(() => Number)
  maxYear?: number;

  @ApiProperty({ required: false, description: 'Number of guests', example: 4 })
  @IsOptional()
  @IsNumber()
  @Min(1)
  @Type(() => Number)
  guests?: number;

  @ApiProperty({
    required: false,
    description: 'Payment type',
    example: 'card',
  })
  @IsOptional()
  @IsString()
  paymentType?: string;

  @ApiProperty({
    required: false,
    description: 'Quick booking available',
    example: true,
  })
  @IsOptional()
  @IsBoolean()
  @Type(() => Boolean)
  quickBooking?: boolean;

  @ApiProperty({ required: false, description: 'Has toilet', example: true })
  @IsOptional()
  @IsBoolean()
  @Type(() => Boolean)
  hasToilet?: boolean;

  @ApiProperty({
    required: false,
    description: 'Departure date',
    example: '2025-12-20',
  })
  @IsOptional()
  @IsDate()
  @Type(() => Date)
  date?: Date;

  @ApiProperty({
    required: false,
    description: 'Departure time',
    example: '08:00',
  })
  @IsOptional()
  @IsString()
  departureTime?: string;

  @ApiProperty({
    required: false,
    description: 'Arrival time',
    example: '20:00',
  })
  @IsOptional()
  @IsString()
  arrivalTime?: string;
}
