Добавлены сервисы

This commit is contained in:
Никита Потапов 2024-01-11 15:44:47 +04:00
parent 31599cd291
commit bd4bcf5e9e
11 changed files with 53 additions and 6 deletions

View File

@ -1,6 +1,5 @@
import { useState } from 'react' import { useState } from 'react'
import { Outlet } from 'react-router-dom'; import { Outlet } from 'react-router-dom';
import { Container } from 'react-bootstrap';
import { CurrentUserContext } from './contexts/CurrentUserContext'; import { CurrentUserContext } from './contexts/CurrentUserContext';
import Header from './components/header/header'; import Header from './components/header/header';
import Footer from './components/footer/footer'; import Footer from './components/footer/footer';

View File

@ -11,7 +11,10 @@ const Header = ({ routes }) => {
const indexPageLink = routes.filter((route) => route.index === false).shift(); const indexPageLink = routes.filter((route) => route.index === false).shift();
const currentPage = routes.filter((route) => route.path === location.pathname)[0]; const currentPage = routes.filter((route) => route.path === location.pathname)[0];
if (currentUser) { if (currentUser) {
routes = routes.filter((route) => route.onlyNoAuthorized != true); routes = routes.filter((route) => !route.onlyNoAuthorized);
}
else {
routes = routes.filter((route) => !route.onlyAuthorized);
} }
return ( return (

View File

@ -9,6 +9,7 @@ import ErrorPage from './pages/ErrorPage/ErrorPage.jsx'
import MainPage from './pages/MainPage/MainPage.jsx' import MainPage from './pages/MainPage/MainPage.jsx'
import AuthPage from './pages/AuthPage/AuthPage.jsx' import AuthPage from './pages/AuthPage/AuthPage.jsx'
import RegisterPage from './pages/RegisterPage/RegisterPage.jsx' import RegisterPage from './pages/RegisterPage/RegisterPage.jsx'
import StatementsPage from './pages/StatementsPage/StatementsPage.jsx'
const routes = [ const routes = [
{ {
@ -17,6 +18,13 @@ const routes = [
element: <MainPage />, element: <MainPage />,
title: 'Главная' title: 'Главная'
}, },
{
path: '/statements',
element: <StatementsPage />,
title: 'Ведомости',
onlyAuthorized: true,
onlyTeachers: true
},
{ {
path: '/auth', path: '/auth',
element: <AuthPage />, element: <AuthPage />,

View File

@ -11,9 +11,12 @@ const AuthPage = () => {
const navigate = useNavigate(); const navigate = useNavigate();
if (currentUser) { useEffect(() => {
navigate('/'); if (currentUser) {
} navigate('/');
}
});
const [inputFields, setInputFields] = useState({ const [inputFields, setInputFields] = useState({
username: "", username: "",

View File

@ -2,7 +2,7 @@
const MainPage = () => { const MainPage = () => {
return ( return (
<> <>
<h1>Hello world!</h1> <h1>Mainpage</h1>
</> </>
); );
}; };

View File

@ -0,0 +1,9 @@
const StatementsPage = () => {
return (
<>
<h5>StatementsPage</h5>
</>
);
};
export default StatementsPage

View File

@ -0,0 +1,5 @@
import ApiService from "../api/ApiService.js";
const ControlTypesApiService = new ApiService("controltypes");
export default ControlTypesApiService;

View File

@ -0,0 +1,5 @@
import ApiService from "../api/ApiService.js";
const MarksApiService = new ApiService("marks");
export default MarksApiService;

View File

@ -0,0 +1,5 @@
import ApiService from "../api/ApiService.js";
const StatementsApiService = new ApiService("statements");
export default StatementsApiService;

View File

@ -0,0 +1,5 @@
import ApiService from "../api/ApiService.js";
const SubjectsApiService = new ApiService("subjects");
export default SubjectsApiService;

View File

@ -0,0 +1,5 @@
import ApiService from "../api/ApiService.js";
const UserMarksApiService = new ApiService("usermarks");
export default UserMarksApiService;