import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator';
import { toBoolean } from '../../../common/utils/query-transform.util';
import { NOTIFICATION_TYPES, NotificationType } from '../schemas/notification.schema';

export const NOTIFICATION_CATEGORIES = [
  'interactions',
  'messages',
  'follows',
  'follow_requests',
  'collaboration',
  'system',
] as const;
export type NotificationCategory = (typeof NOTIFICATION_CATEGORIES)[number];

export class NotificationUnreadCountQueryDto {
  @ApiPropertyOptional({ enum: NOTIFICATION_CATEGORIES })
  @IsOptional()
  @IsEnum(NOTIFICATION_CATEGORIES)
  category?: NotificationCategory;
}

export class NotificationQueryDto extends PaginationQueryDto {
  @ApiPropertyOptional({ default: false })
  @IsOptional()
  @Transform(toBoolean)
  @IsBoolean()
  read?: boolean;

  @ApiPropertyOptional({ enum: NOTIFICATION_TYPES })
  @IsOptional()
  @IsEnum(NOTIFICATION_TYPES)
  type?: NotificationType;

  @ApiPropertyOptional({ example: 'comment' })
  @IsOptional()
  @IsString()
  resourceType?: string;

  @ApiPropertyOptional({ enum: NOTIFICATION_CATEGORIES })
  @IsOptional()
  @IsEnum(NOTIFICATION_CATEGORIES)
  category?: NotificationCategory;
}
