import { Navigate, useLocation } from 'react-router-dom'; import { Result } from 'antd'; import { useAppSelector } from '../store/hooks'; import { selectIsAuthenticated, selectUserInfo } from '../store/slices/authSlice'; export default function RequireSuperAdmin({ children }: { children: React.ReactNode }) { const isAuth = useAppSelector(selectIsAuthenticated); const userInfo = useAppSelector(selectUserInfo); const location = useLocation(); if (!isAuth) { return ; } if (userInfo?.userType !== 'SUPER_ADMIN') { return (
); } return <>{children}; }