1
|
import 'antd/dist/antd.css';
|
2
|
import React, { useContext, useEffect } from 'react';
|
3
|
|
4
|
import { useUnauthRedirect } from '../../../hooks';
|
5
|
import { useRouter } from 'next/router';
|
6
|
import { Layout, Typography } from 'antd';
|
7
|
import UserNavBar from '../../../components/navigation/UserNavBar';
|
8
|
import { faFileLines } from '@fortawesome/free-solid-svg-icons';
|
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
10
|
import { LoggedUserContext } from '../../../contexts/LoggedUserContext';
|
11
|
import { MainLayout } from '../../../layouts/MainLayout';
|
12
|
|
13
|
function UserDocumentPage() {
|
14
|
const redirecting = useUnauthRedirect('/login');
|
15
|
const { logout, role } = useContext(LoggedUserContext);
|
16
|
const router = useRouter();
|
17
|
|
18
|
useEffect(() => {
|
19
|
if (role !== 'ANNOTATOR') {
|
20
|
logout();
|
21
|
router.push('/login');
|
22
|
}
|
23
|
|
24
|
if (!redirecting) {
|
25
|
// TODO load documents
|
26
|
}
|
27
|
}, [logout, redirecting, role, router]);
|
28
|
|
29
|
return redirecting || role !== 'ANNOTATOR' ? null : (
|
30
|
<MainLayout>
|
31
|
<Typography.Title level={2}>
|
32
|
<FontAwesomeIcon icon={faFileLines} /> Dokumenty
|
33
|
</Typography.Title>
|
34
|
</MainLayout>
|
35
|
);
|
36
|
}
|
37
|
|
38
|
export default UserDocumentPage;
|