lab8 some minor fixes
This commit is contained in:
parent
894fc76962
commit
8a650a6b9e
@ -20,7 +20,8 @@ const UserPageInfo = () => {
|
||||
<Button as={Link} to="/user-favorities" className='lib-btn'>Избранное</Button>
|
||||
<Button as={Link} to="/user-history" className='lib-btn'>История</Button>
|
||||
<Button className='lib-btn' onClick={userLogout}>Выйти</Button>
|
||||
<Button as={Link} to="/admin-page" className='lib-btn'>Страница администратора</Button>
|
||||
{user.role === 'admin'
|
||||
&& <Button as={Link} to="/admin-page" className='lib-btn'>Страница администратора</Button>}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
@ -1,7 +1,22 @@
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import AuthorizationForm from '../components/users/authorization/form/AuthorizationForm.jsx';
|
||||
import useUserObject from '../components/users/hooks/UserObjectHook';
|
||||
import ErrorPage from './ErrorPage.jsx';
|
||||
|
||||
const AdminPage = () => {
|
||||
const id = parseInt(localStorage.getItem('userId'), 10);
|
||||
const { user } = useUserObject(id);
|
||||
if (!id) {
|
||||
return (
|
||||
<AuthorizationForm/>
|
||||
);
|
||||
}
|
||||
if (user && user.role && user.role !== 'admin') {
|
||||
return (
|
||||
<ErrorPage/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<h1 className='mt-2 text-md-start text-center'>
|
||||
@ -13,8 +28,6 @@ const AdminPage = () => {
|
||||
</p>
|
||||
<div className="d-grid gap-2 mt-2 d-md-flex justify-content-md-start">
|
||||
<Button as={Link} to="/books-table" className='lib-btn'>Таблица книг</Button>
|
||||
<Button as={Link} to="/categories-table" className='lib-btn'>Страница категорий</Button>
|
||||
<Button as={Link} to="/authors-table" className='lib-btn'>Таблица авторов</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
@ -1,6 +1,21 @@
|
||||
import Lines from '../components/lines/table/Lines.jsx';
|
||||
import AuthorizationForm from '../components/users/authorization/form/AuthorizationForm.jsx';
|
||||
import useUserObject from '../components/users/hooks/UserObjectHook';
|
||||
import ErrorPage from './ErrorPage.jsx';
|
||||
|
||||
const BooksTable = () => {
|
||||
const id = parseInt(localStorage.getItem('userId'), 10);
|
||||
const { user } = useUserObject(id);
|
||||
if (!id) {
|
||||
return (
|
||||
<AuthorizationForm/>
|
||||
);
|
||||
}
|
||||
if (user && user.role && user.role !== 'admin') {
|
||||
return (
|
||||
<ErrorPage/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<h1 className='mt-2 text-md-start text-center'>
|
||||
|
@ -1,18 +1,15 @@
|
||||
import AuthorizationForm from '../components/users/authorization/form/AuthorizationForm.jsx';
|
||||
import UserPageInfo from '../components/users/userPage/UserPageInfo.jsx';
|
||||
// import useAuthorization from '../components/users/context_hooks/AuthorizationHook';
|
||||
|
||||
const UserPage = () => {
|
||||
// let { id } = useAuthorization();
|
||||
let id = localStorage.getItem('userId');
|
||||
id = parseInt(id, 10);
|
||||
const id = parseInt(localStorage.getItem('userId'), 10);
|
||||
if (!id) {
|
||||
return (
|
||||
<AuthorizationForm />
|
||||
<AuthorizationForm/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<UserPageInfo />
|
||||
<UserPageInfo/>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user