import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { ArrayMinSize, IsArray, IsBoolean, IsIn, IsOptional, IsString, MaxLength } from 'class-validator';
import { toBoolean } from '../../../common/utils/query-transform.util';
import { SUPERADMIN_CASE_PRIORITIES } from '../schemas/superadmin-case.schema';

const BULK_RESOURCE_TYPES = ['post', 'comment', 'user', 'listing', 'repair_shop'] as const;

export class BulkSuperAdminActionDto {
  @ApiProperty({ enum: BULK_RESOURCE_TYPES })
  @IsIn(BULK_RESOURCE_TYPES)
  resourceType!: (typeof BULK_RESOURCE_TYPES)[number];

  @ApiProperty({ type: [String] })
  @IsArray()
  @ArrayMinSize(1)
  @IsString({ each: true })
  targetIds!: string[];

  @ApiProperty()
  @IsString()
  @MaxLength(60)
  action!: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(1200)
  reason?: string;

  @ApiPropertyOptional({ enum: SUPERADMIN_CASE_PRIORITIES })
  @IsOptional()
  @IsIn(SUPERADMIN_CASE_PRIORITIES)
  priority?: (typeof SUPERADMIN_CASE_PRIORITIES)[number];

  @ApiPropertyOptional()
  @IsOptional()
  @Transform(toBoolean)
  @IsBoolean()
  assignToMe?: boolean;
}
