import { IsString, IsOptional, IsBoolean, IsArray, ValidateNested, IsNumber, IsEnum } from 'class-validator'
import { Type } from 'class-transformer'

export class FormFieldMappingDto {
  @IsString() fieldId: string
  @IsString() label: string
  @IsNumber() page: number
  @IsNumber() x: number
  @IsNumber() y: number
  @IsNumber() fontSize: number
  @IsOptional() @IsString() fontFamily?: string
  @IsString() dataSource: string
  @IsOptional() @IsString() staticValue?: string
  @IsOptional() @IsNumber() maxLength?: number
  @IsOptional() @IsString() dateFormat?: string
}

export class CreateFormTemplateDto {
  @IsString() name: string
  @IsOptional() @IsString() description?: string

  @IsOptional()
  @IsEnum(['immigration','corporate','civil_litigation','property','family','employment','criminal','other','universal'])
  practiceArea?: string

  @IsString() storageKey: string
  @IsOptional() @IsString() originalFilename?: string

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => FormFieldMappingDto)
  fields: FormFieldMappingDto[]

  @IsOptional() @IsBoolean() isActive?: boolean
  @IsOptional() @IsString() notes?: string
}
