import { ApiProperty } from "@nestjs/swagger"
import { Type } from "class-transformer"
import {
  IsArray,
  IsBoolean,
  IsOptional,
  IsString,
  ValidateNested,
} from "class-validator"

export class CustomerPhoneNumberDto {
  @ApiProperty({ example: "+971", description: "Country code" })
  @IsString()
  country_code: string

  @ApiProperty({ example: "1234567890", description: "Phone number" })
  @IsString()
  phone_number: string

  @ApiProperty({
    example: "mobile",
    description: "Type of phone number",
    required: false,
  })
  @IsOptional()
  @IsString()
  type?: string

  @ApiProperty({ example: true, description: "Is primary", required: false })
  @IsOptional()
  @IsBoolean()
  is_primary?: boolean
}

export class SaveCustomerPhoneNumbersDto {
  @ApiProperty({
    type: [CustomerPhoneNumberDto],
    description: "List of phone numbers to save",
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CustomerPhoneNumberDto)
  phone_numbers: CustomerPhoneNumberDto[]
}
