import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';

/**
 * DTO for searching associates.
 *
 * This DTO allows filtering associates based on:
 * 1. Association type (required)
 * 2. Optional country
 * 3. Optional product
 *
 * It is typically used for API endpoints that return a filtered list of associates.
 */
export class SearchAssociatesDto {
  /**
   * Type of association to filter by (required)
   *
   * Example values:
   * - "INSTITUTE"
   * - "AGENT"
   *
   * Validation:
   * - Must be a non-empty string
   */
  @ApiProperty({ description: 'Type of association (required)' })
  @IsNotEmpty({ message: 'Association type is required' })
  @IsString({ message: 'Association type must be a string' })
  association_type: string;

  /**
   * Optional country filter
   *
   * Allows filtering associates by country.
   *
   * Validation:
   * - Must be a string if provided
   */
  @ApiPropertyOptional({
    description: 'Filter associates by country (optional)',
  })
  @IsOptional()
  @IsString({ message: 'Country ID must be a string' })
  country_id?: string;

  /**
   * Optional product filter
   *
   * Allows filtering associates associated with a specific product.
   *
   * Validation:
   * - Must be a string if provided
   */
  @ApiPropertyOptional({
    description: 'Filter associates by product (optional)',
  })
  @IsOptional()
  @IsString({ message: 'Product ID must be a string' })
  product_id?: string;
}
