import { Type } from 'class-transformer';
import { IsIn, IsInt, IsOptional, IsString, Min } from 'class-validator';
import { TASK_PRIORITIES } from './create-task.dto';

export const TASK_VIEWS = ['open', 'today', 'upcoming', 'overdue', 'done', 'all'] as const;
export type TaskView = (typeof TASK_VIEWS)[number];

export class ListTasksQuery {
  @IsOptional()
  @IsIn(TASK_VIEWS)
  view?: TaskView;

  @IsOptional()
  @IsIn(TASK_PRIORITIES)
  priority?: string;

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

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

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

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

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

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

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

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

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