import { createContext, useContext, useState } from 'react'
const Visitor = createContext()
/** @type {import('../api').SecureUser} */
const unknownUser = {
uid: -1
}
/**
* @param { import('react').PropsWithChildren<{}> } props
*/
export function VisitorProvider({ children }) {
const state = useState(unknownUser)
return {children}
}
/**
* Visitor hook
* @returns {[
* import('../api').SecureUser,
* 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
}