bookwiz.io / lib / contexts / NewBookDialogContext.tsx
NewBookDialogContext.tsx
Raw
'use client'

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

interface NewBookDialogContextType {
  isOpen: boolean
  openDialog: () => void
  closeDialog: () => void
}

export const NewBookDialogContext = createContext<NewBookDialogContextType | undefined>(undefined)

export const useNewBookDialog = () => {
  const context = useContext(NewBookDialogContext)
  if (!context) {
    throw new Error('useNewBookDialog must be used within a DashboardLayout')
  }
  return context
}