import type { IntlShape } from "react-intl"

import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { RoomPrice } from "@/types/components/hotelReservation/enterDetails/details"
import type { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay"
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
import type { Packages } from "@/types/components/myPages/myStay/ancillaries"
import type { Hotel, Room as HotelRoom, RoomCategories } from "@/types/hotel"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
import type { CreditCard } from "@/types/user"

export type Room = Omit<
  BookingConfirmation["booking"],
  "packages" | "roomPrice"
> & {
  bedType: BedTypeSchema
  breakfast: Omit<BreakfastPackage, "requestedPrice"> | undefined | false
  breakfastChildren: Omit<BreakfastPackage, "requestedPrice"> | null
  childrenAsString: string
  childrenInRoom: Child[]
  isCancelled: boolean
  mainRoom: boolean
  originalPackages: BookingConfirmation["booking"]["packages"]
  packages: Packages | null
  priceType: PriceTypeEnum
  rate: string
  room: (HotelRoom & { bedType: HotelRoom["roomTypes"][number] }) | null
  roomName: string
  roomNumber: number
  roomPrice: RoomPrice
  terms: string | null
}

export type BookingRoom = BookingConfirmation["booking"]

interface Actions {
  closeManageStay: () => void
  openManageStay: () => void
}

export interface MyStayState {
  actions: Actions
  allRoomsAreCancelled: boolean
  bookedRoom: Room
  breakfastPackages: Packages | null
  hotel: Hotel
  mainRoom: Room
  manageStay: boolean
  refId: string
  rooms: Room[]
  savedCreditCards: CreditCard[] | null
  totalPoints: number
  totalPrice: string
}

export interface InitialState
  extends Pick<
    MyStayState,
    "breakfastPackages" | "hotel" | "refId" | "savedCreditCards"
  > {
  intl: IntlShape
  roomCategories: RoomCategories
  rooms: BookingRoom[]
}
