import { createContext, useState, useContext, type PropsWithChildren, type SetStateAction, type Dispatch, } from 'react' type AdminProfile = { name: string } type AdminContextProperties = { adminProfile: AdminProfile setAdminProfile: Dispatch> } const AdminContext = createContext( undefined, ) export const AdminProvider = ({ children }: PropsWithChildren) => { const [adminProfile, setAdminProfile] = useState({ name: '', }) return ( {children} ) } export const useAdminContext = (): AdminContextProperties => { const context = useContext(AdminContext) if (!context) { throw new Error('useAdminContext must be used within a AdminProvider') } return context }