'use client' import { createContext, useContext } from 'react' export type AdminRole = 'SUPER_ADMIN' | 'ADMIN' | 'SUPPORT' | 'FINANCE' | 'VIEWER' export type AdminSessionUser = { id: string email: string role: AdminRole totpEnabled?: boolean } const METRICS_ALLOWED_ROLES = new Set(['SUPER_ADMIN', 'ADMIN', 'SUPPORT', 'FINANCE']) const AdminSessionContext = createContext(null) export function AdminSessionProvider({ admin, children, }: { admin: AdminSessionUser children: React.ReactNode }) { return {children} } export function useAdminSession() { return useContext(AdminSessionContext) } export function canAccessAdminMetrics(admin: Pick | null | undefined) { return Boolean(admin && admin.totpEnabled && METRICS_ALLOWED_ROLES.has(admin.role)) }