import { createContext, useContext, useState } from 'react'
const Visitor = createContext()
/**
* @param { import('react').PropsWithChildren<{}> & {
* auth?: import('../api').SecureUser
* }} props
*/
export function VisitorProvider({ auth, children }) {
const state = useState(auth)
return {children}
}
/**
* Visitor hook
* @returns {[
* (import('../api').SecureUser|undefined),
* import('react').Dispatch>
* ]} visitor hook
*/
export function useVisitor() {
const visitor = useContext(Visitor)
if (visitor === undefined) {
throw new Error('useVisitor must be used within a VisitorProvider')
}
return visitor
}