import {
  IsEnum,
  IsInt,
  IsOptional,
  IsString,
  Max,
  Min,
} from 'class-validator';
import { Type } from 'class-transformer';

import { DocumentStatus } from '../entities/document.entity';

/**
 * Filters for the documents list endpoint.
 * - Admin (super-admin) sees all documents.
 * - Staff sees only documents assigned to at least one of their roles
 *   (handled inside the service — this DTO just carries filters).
 */
export class ListDocumentsQueryDto {
  @IsOptional()
  @IsString()
  category?: string;

  @IsOptional()
  @IsEnum(DocumentStatus)
  status?: DocumentStatus;

  @IsOptional()
  @IsInt()
  @Type(() => Number)
  role_id?: number;

  @IsOptional()
  @IsString()
  search?: string;

  @IsOptional()
  @IsInt()
  @Min(1)
  @Type(() => Number)
  page?: number;

  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(100)
  @Type(() => Number)
  limit?: number;
}
