Fakultas Ilmu Komputer UI

TopMenu.jsx 1.13 KB
Newer Older
1
2
3
import React from 'react';
import { Menu, Image } from 'semantic-ui-react';
import { Link } from 'react-router';
4
import Server from '../lib/Server';
5
6
7

export default class TopMenu extends React.Component {
  state = { activeItem: 'home' };
sirinbaisa's avatar
sirinbaisa committed
8
    handleItemClick = (e, { name }) => this.setState({ activeItem: name })
9
  render() {
sirinbaisa's avatar
sirinbaisa committed
10
11
    const { activeItem } = this.state;

12
    return (
sirinbaisa's avatar
sirinbaisa committed
13
      <Menu color='blue' pointing secondary>
14
15
        <Image as="a" size="small" src="/assets/img/logo.png" href="/" />
        <Menu.Menu position="right">
sirinbaisa's avatar
sirinbaisa committed
16
17
          <Menu.Item as={Link} to="/lowongan" name='home'  active={activeItem === 'home'} onClick={this.handleItemClick} />
          <Menu.Item as={Link} to="/profile" name='profil' active={activeItem === 'profil'} onClick={this.handleItemClick}/>
18
          {Server.isLoggedIn() ?
sirinbaisa's avatar
sirinbaisa committed
19
20
            <Menu.Item as={Link} href="/api/api-auth/logout/?next=/" name='logout' active={activeItem === 'logout'} onClick={this.handleItemClick}/> :
            <Menu.Item as={Link} to="/login" name='login' active={activeItem === 'login'} onClick={this.handleItemClick} />
21
22
23
24
25
26
                }
        </Menu.Menu>
      </Menu>
    );
  }
}