import {
  IsString,
  IsOptional,
  IsEmail,
  MaxLength,
  IsEnum,
  IsInt,
  Min,
  Max,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';

export class RegisterIssuerDto {
  @ApiProperty({ maxLength: 200 })
  @IsString()
  @MaxLength(200)
  companyName: string;

  @ApiProperty({ maxLength: 100 })
  @IsString()
  @MaxLength(100)
  contactName: string;

  @ApiProperty({ maxLength: 20 })
  @IsString()
  @MaxLength(20)
  contactPhone: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsEmail()
  contactEmail?: string;

  @ApiPropertyOptional({ maxLength: 100 })
  @IsOptional()
  @IsString()
  @MaxLength(100)
  businessLicense?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  description?: string;

  @ApiPropertyOptional({ maxLength: 500 })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  logoUrl?: string;
}

export class ListIssuersQueryDto {
  @ApiPropertyOptional({ default: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ default: 20 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  limit?: number = 20;

  @ApiPropertyOptional({ enum: ['pending', 'active', 'suspended', 'rejected'] })
  @IsOptional()
  @IsString()
  status?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  search?: string;
}

export class RejectIssuerDto {
  @ApiProperty({ description: 'Reason for rejecting the issuer application' })
  @IsString()
  @MaxLength(1000)
  reason: string;
}
