import type { ChildBedTypeEnum } from "@/constants/booking"
import type { CurrencyEnum } from "../enums/currency"
import type { RoomCategories } from "../hotel"
import type {
  BookingConfirmation,
  PackageSchema,
} from "../trpc/routers/booking/confirmation"

export interface ChildBedPreference {
  quantity: number
  bedType: ChildBedTypeEnum
}

export interface Room {
  adults: number
  bedDescription: string
  bookingCode: string | null
  breakfast: PackageSchema | false | undefined
  breakfastIncluded: boolean
  cheques: number
  childBedPreferences: ChildBedPreference[]
  childrenAges?: number[]
  confirmationNumber: string
  currencyCode: CurrencyEnum
  fromDate: Date
  name: string
  packages: BookingConfirmation["booking"]["packages"]
  formattedRoomCost: string
  rateDefinition: BookingConfirmation["booking"]["rateDefinition"]
  refId: string
  roomFeatures?: PackageSchema[] | null
  roomPoints: number
  roomPrice: number
  roomTypeCode: string | null
  toDate: Date
  totalPrice: number
  totalPriceExVat: number
  vatAmount: number
  vouchers: number
}

export interface InitialState {
  bookingCode: string | null
  fromDate: Date
  rooms: (Room | null)[]
  toDate: Date
  currencyCode: CurrencyEnum
  roomCategories: RoomCategories
  vat: number
  isVatCurrency: boolean
  formattedTotalCost: string
  totalBookingPrice: number
  totalBookingCheques: number
}

export interface BookingConfirmationState extends InitialState {
  actions: {
    setRoom: (room: Room, idx: number) => void
    setFormattedTotalCost: (formattedTotalCost: string) => void
  }
}
