import { useNavigate } from 'react-router-dom'; import { useAuth } from '../hooks/useAuth'; import Button from './ui/Button'; interface RoleGuardProps { allowedRoles: string[]; children: React.ReactNode; } const RoleGuard = ({ allowedRoles, children }: RoleGuardProps) => { const { user } = useAuth(); const navigate = useNavigate(); if (!user || !allowedRoles.includes(user.role)) { return (

접근 권한이 없습니다

이 페이지는 {allowedRoles.join(', ')} 권한이 필요합니다.
현재 권한: {user?.role || '-'}

); } return <>{children}; }; export default RoleGuard;