import { create } from "zustand"

import { SidePeekEnum } from "@/types/components/hotelReservation/sidePeek"

interface SidePeekState {
  activeSidePeek: SidePeekEnum | null
  hotelId: string | null
  roomTypeCode: string | null
  showCTA: boolean
  openSidePeek: ({
    key,
    hotelId,
    roomTypeCode,
    showCTA,
  }: {
    key: SidePeekEnum | null
    hotelId: string
    roomTypeCode?: string
    showCTA?: boolean
  }) => void
  closeSidePeek: () => void
}

const useSidePeekStore = create<SidePeekState>((set) => ({
  activeSidePeek: null,
  hotelId: null,
  roomTypeCode: null,
  showCTA: true,
  openSidePeek: ({ key, hotelId, roomTypeCode, showCTA }) =>
    set({ activeSidePeek: key, hotelId, roomTypeCode, showCTA }),
  closeSidePeek: () =>
    set({ activeSidePeek: null, hotelId: null, roomTypeCode: null }),
}))

export default useSidePeekStore
