import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';
import { IsBoolean, IsEnum, IsNumber, IsOptional, Max, Min } from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { PostType } from '../../../common/enums/post-type.enum';
import { toBoolean } from '../../../common/utils/query-transform.util';

export const FEED_POST_TYPE_FILTERS = [...Object.values(PostType), 'reel'] as const;
export type FeedPostTypeFilter = (typeof FEED_POST_TYPE_FILTERS)[number];

export class FeedQueryDto extends PaginationQueryDto {
  @IsOptional()
  @IsEnum(FEED_POST_TYPE_FILTERS)
  preferredPostType?: FeedPostTypeFilter;

  @IsOptional()
  @Transform(toBoolean)
  @IsBoolean()
  followingOnly?: boolean;

  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(1)
  @Max(500)
  radiusKm?: number;

  @IsOptional()
  @Transform(toBoolean)
  @IsBoolean()
  includeSuggestions?: boolean;

  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(2)
  @Max(10)
  suggestionInterval?: number;
}
