import { createContext, useState, useContext, type PropsWithChildren, type Dispatch, type SetStateAction, } from 'react' type TUpload = | 'featured_image' | 'ads' | 'content' | 'profile_picture' | undefined type AdminContextProperties = { isUploadOpen: TUpload setIsUploadOpen: Dispatch> } const AdminContext = createContext( undefined, ) export const AdminProvider = ({ children }: PropsWithChildren) => { const [isUploadOpen, setIsUploadOpen] = useState() return ( {children} ) } export const useAdminContext = (): AdminContextProperties => { const context = useContext(AdminContext) if (!context) { throw new Error('useAdminContext must be used within a AdminProvider') } return context }