import {Navigate, Outlet} from "react-router-dom"; import {useGetAuthenticatedUserDataQuery} from "../Api/usersApi.js"; import LoadingIndicator from "../Components/Widgets/LoadingIndicator/LoadingIndicator.jsx"; import {Result} from "antd"; const AdminRoute = () => { const { data: user, isLoading: isUserLoading, isError: isUserError, } = useGetAuthenticatedUserDataQuery(undefined, { pollingInterval: 20000, }); if (isUserLoading) { return ; } if (isUserError) { return ; } if (!user) { return ; } if (!user.role || user.role.title !== "Администратор") { return ; } return ; }; export default AdminRoute;