import { IsString, IsOptional, IsEnum, IsNotEmpty } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { DisputeType, DisputeStatus } from '../../../domain/entities/dispute.entity';
import { PaginationQueryDto } from './pagination.dto';

// ───────────── List Disputes ─────────────

export class ListDisputesQueryDto extends PaginationQueryDto {
  @ApiPropertyOptional({ description: 'Filter by dispute status', enum: DisputeStatus })
  @IsOptional()
  @IsEnum(DisputeStatus)
  status?: string;

  @ApiPropertyOptional({ description: 'Filter by dispute type', enum: DisputeType })
  @IsOptional()
  @IsEnum(DisputeType)
  type?: string;
}

// ───────────── Resolve Dispute ─────────────

export class ResolveDisputeDto {
  @ApiProperty({ description: 'Resolution description' })
  @IsString()
  @IsNotEmpty()
  resolution: string;

  @ApiProperty({
    description: 'Resolution status',
    enum: ['resolved', 'rejected'],
  })
  @IsEnum(['resolved', 'rejected'] as const, {
    message: 'status must be either "resolved" or "rejected"',
  })
  status: 'resolved' | 'rejected';
}

// ───────────── Arbitrate Dispute ─────────────

export class ArbitrateDisputeDto {
  @ApiProperty({ description: 'Arbitration decision' })
  @IsString()
  @IsNotEmpty()
  decision: string;

  @ApiPropertyOptional({ description: 'Additional notes' })
  @IsOptional()
  @IsString()
  notes?: string;
}
