import { useAuthStore } from '../stores/auth'; type DashboardRole = 'doctor' | 'health_manager' | 'nurse' | 'admin' | 'operator'; const ROLE_PRIORITY: DashboardRole[] = ['doctor', 'health_manager', 'nurse', 'admin', 'operator']; export function useDashboardRole(): DashboardRole { const user = useAuthStore(s => s.user); if (!user?.roles?.length) return 'admin'; const codes = user.roles.map(r => r.code); for (const role of ROLE_PRIORITY) { if (codes.some(c => c === role || c.startsWith(role))) return role; } return 'admin'; } export type { DashboardRole };