Projekt

Obecné

Profil

Stáhnout (1.2 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 { faFileLines, faUser } from '@fortawesome/free-solid-svg-icons';
6
import { LoggedUserContext } from '../../contexts/LoggedUserContext';
7

    
8
const UserNavBar = () => {
9
    const router = useRouter();
10
    const { logout } = useContext(LoggedUserContext);
11
    const { SubMenu } = Menu;
12

    
13
    const handleLogout = useCallback(() => {
14
        logout();
15
        router.push('/login');
16
    }, [logout, router]);
17

    
18
    return (
19
        <Menu theme="dark" mode="horizontal">
20
            <Menu.Item key="1" onClick={() => router.push('/documents/annotator')}>
21
                <FontAwesomeIcon icon={faFileLines} /> Dokumenty
22
            </Menu.Item>
23

    
24
            <SubMenu
25
                key="account"
26
                icon={<FontAwesomeIcon icon={faUser} />}
27
                title={'Anotátor XY'} // TODO show username
28
            >
29
                <Menu.Item key="setting:2" onClick={() => handleLogout()}>
30
                    Odhlásit se
31
                </Menu.Item>
32
            </SubMenu>
33
        </Menu>
34
    );
35
};
36

    
37
export default UserNavBar;
(2-2/2)