import { IsOptional, IsNumber, IsString, IsIn, IsEnum } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { ContactStatusEnum } from '../interface/interface';

const sortOrderOptions = ['asc', 'desc'] as const;
type SortOrder = (typeof sortOrderOptions)[number];

export class FindContactsDto {
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @ApiPropertyOptional({ example: 1, description: 'Page number', minimum: 1, default: 1 })
  page?: number = 1;

  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  @ApiPropertyOptional({ example: 10, description: 'Items per page', minimum: 1, default: 10 })
  limit?: number = 10;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ example: 'menu', description: 'Search in subject, content, or phone' })
  search?: string;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ example: 'createdAt', description: 'Field to sort by', default: 'createdAt' })
  orderBy?: string = 'createdAt';

  @IsOptional()
  @IsIn(sortOrderOptions)
  @ApiPropertyOptional({ example: 'desc', enum: sortOrderOptions, default: 'desc' })
  order?: SortOrder = 'desc';

  @IsOptional()
  @IsEnum(ContactStatusEnum)
  @ApiPropertyOptional({ enum: ContactStatusEnum, description: 'Filter by status' })
  status?: ContactStatusEnum;

}
