"use client"
import { useMyStayStore } from "@/stores/my-stay"

import CannotChangeDate from "./CannotChangeDate"
import MultiRoomBooking from "./MultiRoomBooking"
import NotMainRoom from "./NotMainRoom"

export default function Alerts({
  children,
  closeModal,
}: React.PropsWithChildren<{ closeModal: () => void }>) {
  const { canChangeDate, mainRoom, multiRoom } = useMyStayStore((state) => ({
    canChangeDate: state.bookedRoom.canChangeDate,
    mainRoom: state.bookedRoom.mainRoom,
    multiRoom: state.bookedRoom.multiRoom,
  }))

  if (multiRoom) {
    return <MultiRoomBooking closeModal={closeModal} />
  }

  if (!mainRoom) {
    return <NotMainRoom closeModal={closeModal} />
  }

  if (!canChangeDate) {
    return <CannotChangeDate closeModal={closeModal} />
  }

  return <>{children}</>
}
