({
children,
})
| 8 | }; |
| 9 | |
| 10 | const AdminProtectedRoute: React.FC<AdminProtectedRoutetypes> = ({ |
| 11 | children, |
| 12 | }) => { |
| 13 | const {user, isloading} = useAuthStore(); |
| 14 | |
| 15 | if (isloading) { |
| 16 | return ( |
| 17 | <Box |
| 18 | sx={{ |
| 19 | display: 'flex', |
| 20 | justifyContent: 'center', |
| 21 | alignItems: 'center', |
| 22 | height: '70vh', |
| 23 | }} |
| 24 | > |
| 25 | <CircularProgress size={100} /> |
| 26 | </Box> |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | if (user?.role !== 'admin') { |
| 31 | toast.error('Your role should be Admin to continue'); |
| 32 | return <Navigate to="/" />; |
| 33 | } |
| 34 | return <>{children}</>; |
| 35 | }; |
| 36 | |
| 37 | export default AdminProtectedRoute; |
nothing calls this directly
no outgoing calls
no test coverage detected