Projekt

Obecné

Profil

Stáhnout (1.93 KB) Statistiky
| Větev: | Tag: | Revize:
1
import React, { useCallback, useContext } from 'react';
2
import { Menu } from 'antd';
3
import { useRouter } from 'next/router';
4
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
import { LoggedUserContext } from '../../contexts/LoggedUserContext';
6
import {
7
    faUser,
8
    faFileExport,
9
    faFileLines,
10
    faUsers,
11
    faTags,
12
    faBookmark,
13
} from '@fortawesome/free-solid-svg-icons';
14

    
15
const AdminNavBar = () => {
16
    const router = useRouter();
17
    const { logout } = useContext(LoggedUserContext);
18
    const { SubMenu } = Menu;
19

    
20
    const handleLogout = useCallback(() => {
21
        logout();
22
        router.push('/login');
23
    }, [logout, router]);
24

    
25
    return (
26
        <Menu theme="dark" mode="horizontal">
27
            <Menu.Item style={{}} key="1" onClick={() => router.push('/documents/admin')}>
28
                <FontAwesomeIcon icon={faFileLines} /> Dokumenty
29
            </Menu.Item>
30
            <Menu.Item style={{}} key="2" onClick={() => router.push('/users')}>
31
                <FontAwesomeIcon icon={faUsers} /> Uživatelé
32
            </Menu.Item>
33
            <Menu.Item style={{}} key="3" onClick={() => router.push('/tags')}>
34
                <FontAwesomeIcon icon={faTags} /> Značky
35
            </Menu.Item>
36
            <Menu.Item style={{}} key="4" onClick={() => router.push('/classes')}>
37
                <FontAwesomeIcon icon={faBookmark} /> Třídy
38
            </Menu.Item>
39
            <Menu.Item style={{}} key="5" onClick={() => router.push('/export')}>
40
                <FontAwesomeIcon icon={faFileExport} /> Export
41
            </Menu.Item>
42

    
43
            <SubMenu
44
                icon={<FontAwesomeIcon icon={faUser} />}
45
                key="account"
46
                title={'Admin XY'} // TODO show username
47
            >
48
                <Menu.Item key="setting:2" onClick={() => handleLogout()}>
49
                    Odhlásit se
50
                </Menu.Item>
51
            </SubMenu>
52
        </Menu>
53
    );
54
};
55

    
56
export default AdminNavBar;
(1-1/2)