"use client"

import { createContext, useContext } from "react"

export type BookingFlowContextData = {
  isLoggedIn: boolean
}

export const BookingFlowContext = createContext<
  BookingFlowContextData | undefined
>(undefined)

export const useBookingFlowContext = (): BookingFlowContextData => {
  const context = useContext(BookingFlowContext)

  if (!context) {
    throw new Error(
      "useBookingFlowContext must be used within a BookingFlowContextProvider. Did you forget to use the provider in the consuming app?"
    )
  }

  return context
}
