import { ApiPropertyOptional } from '@nestjs/swagger';
import { IndustrialParkStatus, VietnamRegion } from '@prisma/client';
import { Type } from 'class-transformer';
import { IsEnum, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';

export class SearchIndustrialParksDto {
  @ApiPropertyOptional({ example: 'VSIP', description: 'Từ khóa tìm kiếm' })
  @IsOptional()
  @IsString()
  q?: string;

  @ApiPropertyOptional({ example: 'Bắc Ninh' })
  @IsOptional()
  @IsString()
  province?: string;

  @ApiPropertyOptional({ enum: VietnamRegion })
  @IsOptional()
  @IsEnum(VietnamRegion)
  region?: VietnamRegion;

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

  @ApiPropertyOptional({ example: 50, description: 'Diện tích trống tối thiểu (ha)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @Min(0)
  minAreaHa?: number;

  @ApiPropertyOptional({ example: 100, description: 'Giá thuê đất tối đa (USD/m²/năm)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  maxRentUsdM2?: number;

  @ApiPropertyOptional({ example: 'electronics' })
  @IsOptional()
  @IsString()
  targetIndustry?: string;

  @ApiPropertyOptional({ example: 1, default: 1 })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @Min(1)
  page?: number;

  @ApiPropertyOptional({ example: 20, default: 20 })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @Min(1)
  @Max(100)
  limit?: number;
}
