import React from 'react' import { Navigate } from 'react-router-dom' import { useAuth } from '../hooks/useAuth' interface RequireRoleProps { allowed: Array<'admin' | 'user' | 'passthrough'> children: React.ReactNode } const RequireRole: React.FC = ({ allowed, children }) => { const { user } = useAuth() if (!user) { return } if (!allowed.includes(user.role)) { const redirectTarget = user.role === 'passthrough' ? '/passthrough' : '/' return } return children } export default RequireRole