import React, { createContext, useContext, useState } from 'react';

interface BookingContextType {
  isOpen: boolean;
  openBookingModal: () => void;
  closeBookingModal: () => void;
}

export const BookingContext = createContext<BookingContextType>({
  isOpen: false,
  openBookingModal: () => {},
  closeBookingModal: () => {},
});

export const useBooking = () => useContext(BookingContext);

export const BookingProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <BookingContext.Provider
      value={{
        isOpen,
        openBookingModal:  () => setIsOpen(true),
        closeBookingModal: () => setIsOpen(false),
      }}
    >
      {children}
    </BookingContext.Provider>
  );
};
