import { ApiProperty } from "@nestjs/swagger"
import { Type } from "class-transformer"
import { IsEnum, IsInt, IsOptional, IsString } from "class-validator"

export enum AddressType {
  HOME = "home",
  WORK = "work",
  OTHER = "other",
  EMERGENCY_CONTACT = "emergency_contact",
}

export class CreateAddressDto {
  @ApiProperty({ example: 1, description: "Address ID (for updates)" })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  id?: number

  @ApiProperty({ example: 1, description: "City ID" })
  @IsOptional()
  city_id: number

  @ApiProperty({ example: 1, description: "Country ID" })
  @IsOptional()
  country_id: number

  @ApiProperty({ example: 1, description: "State ID" })
  @IsOptional()
  state_id: number

  @ApiProperty({ example: "123 Main St", description: "Address Line 1" })
  @IsString()
  @IsOptional()
  address_line_1: string

  @ApiProperty({ example: "Apt 4B", description: "Address Line 2" })
  @IsOptional()
  @IsString()
  address_line_2?: string

  @ApiProperty({ example: "10001", description: "Zipcode" })
  @IsString()
  @IsOptional()
  zipcode: string

  @ApiProperty({
    enum: AddressType,
    example: AddressType.HOME,
    description: "Address Type (home/work/other)",
  })
  @IsEnum(AddressType)
  address_type: AddressType

  @ApiProperty({ example: false, description: "Is Emergency Contact" })
  @IsOptional()
  @IsString()
  is_emergency_contact?: string
}
