import { ApiProperty } from "@nestjs/swagger"
import {
  IsEmail,
  IsInt,
  IsNotEmpty,
  IsOptional,
  IsString,
} from "class-validator"
import { messageKey } from "src/constants/message-keys"
import { validationMessage } from "src/utils/helpers"

export class CreateClientsCompanyDto {
  @ApiProperty({
    example: "Sunrise Medical Center",
    description: "Name of the company",
  })
  @IsString()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "company_name",
    }),
  })
  company_name: string

  @ApiProperty({
    example: "123 Main Street",
    description: "Primary address line",
    required: false,
  })
  @IsOptional()
  @IsString()
  address_line_1?: string

  @ApiProperty({
    example: "Suite 200",
    description: "Secondary address line",
    required: false,
  })
  @IsOptional()
  @IsString()
  address_line_2?: string

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

  @ApiProperty({
    example: 2,
    description: "State ID",
    required: false,
  })
  @IsOptional()
  @IsInt()
  state_id?: number

  @ApiProperty({
    example: 91,
    description: "Country ID",
    required: false,
  })
  @IsOptional()
  @IsInt()
  country_id?: number

  @ApiProperty({
    example: "560001",
    description: "Zip/Postal code",
    required: false,
  })
  @IsOptional()
  @IsString()
  zip_code?: string

  @ApiProperty({
    example: "+91-9876543210",
    description: "Phone number",
  })
  @IsString()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "phone_number",
    }),
  })
  phone_number: string

  @ApiProperty({
    example: "+91",
    description: "Country code (e.g. +91)",
  })
  @IsString()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "country_code",
    }),
  })
  country_code: string

  @ApiProperty({
    example: "info@sunrisemedical.com",
    description: "Email address",
  })
  @IsEmail()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "email",
    }),
  })
  email: string

  @ApiProperty({
    example: "https://www.sunrisemedical.com",
    description: "Website URL",
    required: false,
  })
  @IsOptional()
  @IsString()
  website_url?: string

  @ApiProperty({
    example: false,
    description: "Is the client a medical patient?",
    required: false,
  })
  @IsOptional()
  is_medical_patient?: string

  @ApiProperty({
    example: 3,
    description: "Client type ID",
  })
  @IsInt()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "client_type_id",
    }),
  })
  client_type_id: number
}
