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

export class SearchIndustrialListingsDto {
  @ApiPropertyOptional({ description: 'Lọc theo KCN' })
  @IsOptional()
  @IsString()
  parkId?: string;

  @ApiPropertyOptional({ enum: IndustrialPropertyType })
  @IsOptional()
  @IsEnum(IndustrialPropertyType)
  propertyType?: IndustrialPropertyType;

  @ApiPropertyOptional({ enum: IndustrialLeaseType })
  @IsOptional()
  @IsEnum(IndustrialLeaseType)
  leaseType?: IndustrialLeaseType;

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

  @ApiPropertyOptional({ example: 1000, description: 'Diện tích tối thiểu (m²)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @Min(0)
  minAreaM2?: number;

  @ApiPropertyOptional({ example: 10000, description: 'Diện tích tối đa (m²)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  maxAreaM2?: number;

  @ApiPropertyOptional({ example: 3, description: 'Giá tối thiểu (USD/m²)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  minPriceUsdM2?: number;

  @ApiPropertyOptional({ example: 10, description: 'Giá tối đa (USD/m²)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  maxPriceUsdM2?: number;

  @ApiPropertyOptional({ example: 'nhà xưởng', description: 'Từ khóa tìm kiếm' })
  @IsOptional()
  @IsString()
  q?: 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;
}
