Projekt

Obecné

Profil

Stáhnout (1.41 KB) Statistiky
| Větev: | Tag: | Revize:
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 { Button, Typography } from 'antd';
7
import { faFileLines } from '@fortawesome/free-solid-svg-icons';
8
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
import { LoggedUserContext } from '../../../contexts/LoggedUserContext';
10
import { MainLayout } from '../../../layouts/mainLayout';
11
import { documentController } from '../../../controllers';
12

    
13
function AdminDocumentPage() {
14
    const redirecting = useUnauthRedirect('/login');
15
    const { logout, role } = useContext(LoggedUserContext);
16
    const router = useRouter();
17
    useEffect(() => {
18
        if (role !== 'ADMINISTRATOR') {
19
            logout();
20
            router.push('/login');
21
        }
22

    
23
        if (!redirecting) {
24
            // TODO load documents
25
        }
26
    }, [logout, redirecting, role, router]);
27

    
28
    const showModal = () => {
29
        // TODO show AddDocument component
30
    };
31

    
32
    return redirecting || role !== 'ADMINISTRATOR' ? null : (
33
        <MainLayout>
34
            <Typography.Title level={2}>
35
                <FontAwesomeIcon icon={faFileLines} /> Dokumenty
36
            </Typography.Title>
37
            <Button type={'primary'} onClick={showModal}>
38
                Nahrát dokument
39
            </Button>
40
        </MainLayout>
41
    );
42
}
43

    
44
export default AdminDocumentPage;
    (1-1/1)