import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsOptional, IsString, IsIn, IsInt, Min, Max, IsDateString } from 'class-validator';

export class GetAuditLogsQueryDto {
  @ApiPropertyOptional({ description: 'Page number', example: 1, minimum: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number;

  @ApiPropertyOptional({ description: 'Items per page', example: 20, minimum: 1, maximum: 100 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  limit?: number;

  @ApiPropertyOptional({
    description: 'Filter by admin action',
    enum: [
      'LISTING_APPROVED',
      'LISTING_REJECTED',
      'LISTING_BULK_APPROVED',
      'LISTING_BULK_REJECTED',
      'USER_BANNED',
      'USER_UNBANNED',
      'USER_STATUS_UPDATED',
      'KYC_APPROVED',
      'KYC_REJECTED',
      'SUBSCRIPTION_ADJUSTED',
    ],
  })
  @IsOptional()
  @IsIn([
    'LISTING_APPROVED',
    'LISTING_REJECTED',
    'LISTING_BULK_APPROVED',
    'LISTING_BULK_REJECTED',
    'USER_BANNED',
    'USER_UNBANNED',
    'USER_STATUS_UPDATED',
    'KYC_APPROVED',
    'KYC_REJECTED',
    'SUBSCRIPTION_ADJUSTED',
  ])
  action?: string;

  @ApiPropertyOptional({ description: 'Filter by admin actor ID' })
  @IsOptional()
  @IsString()
  actorId?: string;

  @ApiPropertyOptional({ description: 'Filter by target entity ID' })
  @IsOptional()
  @IsString()
  targetId?: string;

  @ApiPropertyOptional({
    description: 'Filter by target type',
    enum: ['USER', 'LISTING', 'SUBSCRIPTION'],
  })
  @IsOptional()
  @IsIn(['USER', 'LISTING', 'SUBSCRIPTION'])
  targetType?: string;

  @ApiPropertyOptional({ description: 'Start date filter (ISO 8601)', example: '2026-01-01T00:00:00.000Z' })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({ description: 'End date filter (ISO 8601)', example: '2026-12-31T23:59:59.999Z' })
  @IsOptional()
  @IsDateString()
  endDate?: string;
}
