import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min } from 'class-validator';
import { Type } from 'class-transformer';
import { QuestionType } from 'src/common/enum/question-type.enum';
import { AnswerType } from 'src/common/enum/answer-type.enum';

export class FilterMasterQuestionDto {
  @ApiProperty({ description: 'Number of records per page', default: 10, required: false })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  limit?: number = 10;

  @ApiProperty({ description: 'Offset for pagination', default: 0, required: false })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(0)
  offset?: number = 0;

  @ApiProperty({ description: 'Search text for question text', required: false })
  @IsOptional()
  @IsString()
  searchText?: string;

  @ApiProperty({ description: 'Filter by active status', required: false })
  @IsOptional()
  @Type(() => Boolean)
  @IsBoolean()
  isActive?: boolean;

  @ApiProperty({ description: 'Filter by section ID', required: false, type: Number })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  masterFormSectionId?: number;

  @ApiProperty({
    description: 'Filter by question type',
    enum: QuestionType,
    required: false,
  })
  @IsOptional()
  @IsEnum(QuestionType)
  questionType?: QuestionType;

  @ApiProperty({
    description: 'Filter by answer type',
    enum: AnswerType,
    required: false,
  })
  @IsOptional()
  @IsEnum(AnswerType)
  answerType?: AnswerType;
}
