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

export class MigrateClientRow {
  @IsOptional() @IsString() externalId?: string
  @IsOptional() @IsString() clientType?: string
  @IsOptional() @IsString() firstName?: string
  @IsOptional() @IsString() lastName?: string
  @IsOptional() @IsString() companyName?: string
  @IsOptional() @IsString() email?: string
  @IsOptional() @IsString() phone?: string
  @IsOptional() @IsString() address?: string
  @IsOptional() @IsString() nationality?: string
  @IsOptional() @IsString() passportNumber?: string
  @IsOptional() @IsString() responsibleAttorney?: string
  @IsOptional() @IsString() originatingAttorney?: string
  @IsOptional() @IsString() status?: string
  @IsOptional() @IsString() engagementDate?: string
  @IsOptional() @IsString() notes?: string
}

export class MigrateMatterRow {
  @IsOptional() @IsString() externalClientId?: string
  @IsOptional() @IsString() externalMatterId?: string
  @IsOptional() @IsString() title?: string
  @IsOptional() @IsString() practiceArea?: string
  @IsOptional() @IsString() subType?: string
  @IsOptional() @IsString() status?: string
  @IsOptional() @IsString() responsibleAttorney?: string
  @IsOptional() @IsString() openedAt?: string
  @IsOptional() @IsString() closedAt?: string
  @IsOptional() @IsString() notes?: string
}

export class MigrateImportDto {
  @IsEnum(['tabs3', 'legaltrek'])
  source: 'tabs3' | 'legaltrek'

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => MigrateClientRow)
  clients: MigrateClientRow[]

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => MigrateMatterRow)
  matters: MigrateMatterRow[]

  @IsString()
  defaultAttorney: string
}
