import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"
import {
  IsArray,
  IsDateString,
  IsEnum,
  IsInt,
  IsObject,
  IsOptional,
  IsString,
} from "class-validator"

export enum LocationType {
  CUSTOM = "custom",
  HOSPITAL = "hospital",
  RESIDENCE = "residence",
}

export class UpdateTripDto {
  @ApiProperty({
    type: "string",
    format: "binary",
    required: false,
    description: "Upload trip document file (e.g., PDF, image, etc.)",
  })
  trip_document: any

  @ApiProperty({
    example: 1,
    description: "Enter the prn number of the customer",
    required: false,
  })
  @IsOptional()
  prn_number?: string

  @ApiProperty({
    example: true,
    description: "Direct customer flag for the trip",
    required: true,
  })
  @IsString()
  @IsOptional()
  is_direct_customer: string

  @ApiProperty({
    example: 101,
    description: "Client ID who owns this trip",
    required: false,
  })
  @IsOptional()
  @IsInt()
  client_id: number

  @ApiProperty({
    example: 200,
    description: "Billing contact ID for this client",
    required: false,
  })
  @IsOptional()
  @IsInt()
  client_contact_billing_id: number

  @ApiProperty({
    example: 300,
    description: "Booking reference from the client",
    required: false,
  })
  @IsOptional()
  @IsInt()
  client_booking_id: number

  @ApiProperty({
    example: 401,
    description: "ID of the customer taking the trip",
    required: false,
  })
  @IsOptional()
  @IsInt()
  customer_id: number

  @ApiProperty({
    example: "+1234567890",
    description: "Phone number of the customer",
    required: false,
  })
  @IsOptional()
  @IsString()
  customer_phone_number?: string

  @ApiProperty({
    example: "john.doe@example.com",
    description: "Email address of the customer",
    required: false,
  })
  @IsOptional()
  @IsString()
  customer_email?: string

  @ApiProperty({
    example: "+91",
    description: "Country code of the customer",
    required: false,
  })
  @IsOptional()
  @IsString()
  customer_country_code?: string

  @ApiProperty({
    example: "REF12345",
    description: "Customer reference number",
    required: false,
  })
  @IsOptional()
  @IsString()
  customer_ref_no?: string

  @ApiProperty({
    example: "REF12345",
    description: "Customer reference number",
    required: false,
  })
  @IsOptional()
  @IsString()
  appointment_type?: string

  @ApiProperty({
    example: 1,
    description: "Trip type ID",
    required: false,
  })
  @IsOptional()
  @IsInt()
  trip_type_id?: number

  @ApiProperty({
    example: 1,
    description: "Enter Episode number",
    required: false,
  })
  @IsOptional()
  @IsInt()
  episode_id?: number

  @ApiProperty({
    example: 1,
    description: "Enter the log",
    required: false,
  })
  @IsOptional()
  @IsInt()
  log_id?: number

  @ApiProperty({
    example: "America/New_York",
    description: "Enter the trip timezone",
    required: false,
  })
  @IsOptional()
  trip_timezone?: string

  @ApiProperty({
    example: "2025-08-01",
    description: "Pick-up date",
    required: false,
  })
  @IsOptional()
  @IsDateString()
  pickup_datetime?: string

  @ApiProperty({
    example: "2025-08-01",
    description: "Drop-off date",
    required: false,
  })
  @IsOptional()
  @IsDateString()
  dropoff_datetime?: string

  @ApiProperty({
    example: "15 minutes",
    description: "Arrive before scheduled pick-up time",
    required: false,
  })
  @IsOptional()
  @IsString()
  arrive_before?: string

  @ApiProperty({
    example: "Main Street, City",
    description: "Pick-up location text",
    required: false,
  })
  @IsOptional()
  @IsString()
  pick_up_location?: string

  @ApiProperty({
    example: "Hospital Lane, City",
    description: "Drop-up location text",
    required: false,
  })
  @IsOptional()
  @IsString()
  drop_off_location?: string

  @ApiProperty({
    example: LocationType.HOSPITAL,
    enum: LocationType,
    description: "Pick-up location type",
    required: false,
  })
  @IsOptional()
  @IsEnum(LocationType)
  pickup_location_type?: LocationType

  @ApiProperty({
    example: 22,
    description: "Hospital ID for pick-up",
    required: false,
  })
  @IsOptional()
  @IsInt()
  pickup_hospital_id?: number

  @ApiProperty({
    example: "Flat 101, Some Residency",
    description: "Custom address for pick-up",
    required: false,
  })
  @IsOptional()
  @IsString()
  pickup_custom_address?: string

  @ApiProperty({
    example: 15,
    description: "Residence ID for pick-up",
    required: false,
  })
  @IsOptional()
  @IsInt()
  pickup_residence_id?: number

  @ApiProperty({
    example: LocationType.RESIDENCE,
    enum: LocationType,
    description: "Drop-off location type",
    required: false,
  })
  @IsOptional()
  @IsEnum(LocationType)
  dropoff_location_type?: LocationType

  @ApiPropertyOptional({
    example: 12,
    description: "Hospital ID for drop-up",
    required: false,
  })
  @IsOptional()
  @IsInt()
  dropoff_hospital_id?: number

  @ApiProperty({
    example: "Tower B, Downtown Ave",
    description: "Custom address for drop-up",
    required: false,
  })
  @IsOptional()
  @IsString()
  dropoff_custom_address?: string

  @ApiProperty({
    example: 35,
    description: "Residence ID for drop-up",
    required: false,
  })
  @IsOptional()
  @IsInt()
  dropoff_residence_id?: number

  @ApiProperty({
    example: "Wheelchair assistance required",
    description: "Any specific service instructions",
    required: false,
  })
  @IsOptional()
  @IsString()
  service_details?: string

  @ApiProperty({
    example: "flight number ",
    description: "Any specific service instructions",
    required: false,
  })
  @IsOptional()
  flight_number?: any

  @ApiProperty({
    example: "flight detail json",
    description: "Any specific service instructions",
    required: false,
  })
  @IsOptional()
  @IsObject()
  flight_details?: any

  @ApiProperty({
    example: "2 large bags",
    description: "Luggage information",
    required: false,
  })
  @IsOptional()
  @IsString()
  luggage_information?: string

  @ApiProperty({
    example: 1,
    description: "Number of taxis required",
    required: false,
  })
  @IsOptional()
  @IsInt()
  no_of_taxi?: number

  @ApiProperty({
    example: true,
    description: "Whether to greet the customer",
    required: false,
  })
  @IsOptional()
  greet_customer?: any

  @ApiProperty({
    example: "Please welcome Mr. John politely",
    description: "Message to show or tell while greeting",
    required: false,
  })
  @IsOptional()
  @IsString()
  greet_message?: string

  @ApiProperty({
    example: true,
    description: "Whether the trip is still open for updates",
    required: false,
  })
  @IsOptional()
  is_trip_open?: any

  @ApiProperty({
    example: true,
    description: "Whether the patient is the passenger",
    required: false,
  })
  @IsOptional()
  is_patient_in_trip?: any

  @ApiProperty({
    example: "DISCOUNT25",
    description: "Promo code used for this trip",
    required: false,
  })
  @IsOptional()
  @IsString()
  promo_code?: string

  @ApiProperty({
    example: "Customer prefers back seat.",
    description: "Any extra instructions or preferences",
    required: false,
  })
  @IsOptional()
  @IsString()
  additional_notes?: string

  @ApiProperty({
    example: "Call dispatch before leaving",
    description: "Note from dispatcher to driver",
    required: false,
  })
  @IsOptional()
  @IsString()
  dispatch_note?: string

  @ApiProperty({
    example: 1,
    description: "Form wizard progress step",
    required: false,
  })
  @IsOptional()
  @IsInt()
  current_step?: number

  @ApiProperty({
    example: 1,
    description: "213213123",
    required: false,
  })
  @IsOptional()
  pickup_latitude?: number

  @ApiProperty({
    example: 1,
    description: "56432567",
    required: false,
  })
  @IsOptional()
  pickup_longitude?: number

  @ApiProperty({
    example: 1,
    description: "56432567",
    required: false,
  })
  @IsOptional()
  dropoff_latitude?: number

  @ApiProperty({
    example: 1,
    description: "56432567",
    required: false,
  })
  @IsOptional()
  dropoff_longitude?: number

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  total_passenger?: number

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  estimated_time?: string

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  estimated_distance?: string

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  last_leg_distance?: string

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  last_leg_time?: string

  @ApiProperty({
    example: 1,
    description: "5",
    required: false,
  })
  @IsOptional()
  status?: string

  @ApiProperty({
    example: "baroda",
    description: "Enter the city name",
    required: false,
  })
  @IsOptional()
  city?: string

  @ApiProperty({
    example: true,
    description:
      "Flag to bypass conflict validation when changing the city. Set this to true only after user confirms that trip add-ons will be removed.",
    required: false,
  })
  @IsOptional()
  force_update?: boolean

  @ApiPropertyOptional({
    type: [Number],
    example: [1, 2, 3],
    description: "Optional list of AddOn IDs to associate with this trip",
  })
  @IsOptional()
  @IsArray()
  // @IsInt({ each: true })
  addons?: number[]

  @ApiPropertyOptional({
    type: [Number],
    example: [1, 2, 3],
    description: "Optional list of AddOn IDs to associate with this trip",
  })
  @IsOptional()
  @IsArray()
  // @IsInt({ each: true })
  escort_ids?: number[]

  document_type?: string

  @ApiProperty({
    example: true,
    description: "Is trip OTP flag",
    required: false,
  })
  @IsOptional()
  is_trip_otp_required?: string

  @ApiProperty({
    example: "ChIJN1t_tDeuEmsRUsoyG83frY4",
    description: "Pickup location place id (e.g., Google Place ID)",
    required: false,
  })
  @IsOptional()
  @IsString()
  pickup_place_id?: string

  @ApiProperty({
    example: "ChIJP3Sa8ziYEmsRUKgyFmh9AQM",
    description: "Dropoff location place id (e.g., Google Place ID)",
    required: false,
  })
  @IsOptional()
  @IsString()
  dropoff_place_id?: string
}
