import { z } from "zod"

import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"

export const getHotelsAvailabilityInputSchema = z.object({
  cityId: z.string(),
  roomStayStartDate: z.string(),
  roomStayEndDate: z.string(),
  adults: z.number(),
  children: z.string().optional(),
  promotionCode: z.string().optional().default(""),
  reservationProfileType: z.string().optional().default(""),
  attachedProfileId: z.string().optional().default(""),
})

export const getRoomsAvailabilityInputSchema = z.object({
  hotelId: z.number(),
  roomStayStartDate: z.string(),
  roomStayEndDate: z.string(),
  adults: z.number(),
  children: z.string().optional(),
  promotionCode: z.string().optional(),
  reservationProfileType: z.string().optional().default(""),
  attachedProfileId: z.string().optional().default(""),
  rateCode: z.string().optional(),
})

export const getSelectedRoomAvailabilityInputSchema = z.object({
  hotelId: z.string(),
  roomStayStartDate: z.string(),
  roomStayEndDate: z.string(),
  adults: z.number(),
  children: z.string().optional(),
  promotionCode: z.string().optional(),
  reservationProfileType: z.string().optional().default(""),
  attachedProfileId: z.string().optional().default(""),
  rateCode: z.string(),
  roomTypeCode: z.string(),
  packageCodes: z.array(z.nativeEnum(RoomPackageCodeEnum)).optional(),
})

export type GetSelectedRoomAvailabilityInput = z.input<
  typeof getSelectedRoomAvailabilityInputSchema
>

export type GetRoomsAvailabilityInput = z.input<
  typeof getRoomsAvailabilityInputSchema
>

export const getRatesInputSchema = z.object({
  hotelId: z.string(),
})

export const getHotelDataInputSchema = z.object({
  hotelId: z.string(),
  language: z.string(),
  isCardOnlyPayment: z.boolean().optional(),
})

export type HotelDataInput = z.input<typeof getHotelDataInputSchema>

export const getBreakfastPackageInputSchema = z.object({
  adults: z.number().min(1, { message: "at least one adult is required" }),
  fromDate: z
    .string()
    .min(1, { message: "fromDate is required" })
    .pipe(z.coerce.date()),
  hotelId: z.string().min(1, { message: "hotelId is required" }),
  toDate: z
    .string()
    .min(1, { message: "toDate is required" })
    .pipe(z.coerce.date()),
})

export const getRoomPackagesInputSchema = z.object({
  hotelId: z.string(),
  startDate: z.string(),
  endDate: z.string(),
  adults: z.number(),
  children: z.number().optional().default(0),
  packageCodes: z.array(z.string()).optional().default([]),
})
