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
8

export default class TopMenu extends React.Component {
  state = { activeItem: 'home' };

sirinbaisa's avatar
sirinbaisa committed
9
    handleItemClick = (e, { name }) => this.setState({ activeItem: name })
10
  render() {
sirinbaisa's avatar
sirinbaisa committed
11
12
    const { activeItem } = this.state;

13
    return (
sirinbaisa's avatar
sirinbaisa committed
14
      <Menu color='blue' pointing secondary>
15
16
        <Image as="a" size="small" src="/assets/img/logo.png" href="/" />
        <Menu.Menu position="right">
sirinbaisa's avatar
sirinbaisa committed
17
18
          <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}/>
19
          {Server.isLoggedIn() ?
sirinbaisa's avatar
sirinbaisa committed
20
21
            <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} />
22
23
24
25
26
27
                }
        </Menu.Menu>
      </Menu>
    );
  }
}