Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit e1c09d89 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140657435] [#40] [Refactor] Add admin act as a company bar

parent d4e22340
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
color:black; color:black;
} }
.item-list {
word-wrap: break-word;
width: 100%;
}
.ui.card.register{ .ui.card.register{
background-color: #EEEEEE; background-color: #EEEEEE;
...@@ -155,6 +159,8 @@ card .formRegis{ ...@@ -155,6 +159,8 @@ card .formRegis{
.ui.pointing.secondary.menu{ .ui.pointing.secondary.menu{
background-color: #ffffff; background-color: #ffffff;
margin-bottom: 10px;
margin-top: 0px;
} }
.extra.extra-company h3{ .extra.extra-company h3{
...@@ -237,3 +243,13 @@ card .formRegis{ ...@@ -237,3 +243,13 @@ card .formRegis{
margin-left: 10%; margin-left: 10%;
margin-right: 10%; margin-right: 10%;
} }
.admin-bar{
margin: 0;
padding: 0 10px 0 0;
width: 100%;
text-align: right;
background-color: #304D8A;
color: white;
}
\ No newline at end of file
...@@ -7,33 +7,55 @@ import Storage from '../lib/Storage'; ...@@ -7,33 +7,55 @@ import Storage from '../lib/Storage';
export default class TopMenu extends React.Component { export default class TopMenu extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired,
};
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
this.state = { activeItem: 'home' }; this.state = { activeItem: 'home' };
this.logout = this.logout.bind(this); this.logout = this.logout.bind(this);
this.logoutCompany = this.logoutCompany.bind(this);
} }
handleItemClick = (e, { name }) => this.setState({ activeItem: name }); handleItemClick = (e, { name }) => this.setState({ activeItem: name });
logout = () => { logout = (e) => {
e.preventDefault();
Server.get('/api-auth/logout/?next=/', true).then(() => { Server.get('/api-auth/logout/?next=/', true).then(() => {
Storage.clear(); Storage.clear();
browserHistory.push('/login'); browserHistory.push('/login');
}); });
}; };
logoutCompany = /* istanbul ignore next */ (e) => {
e.preventDefault();
const userData = Storage.get('user-data');
userData.company = null;
Storage.set('user-data', userData);
window.location.replace('/home');
};
render() { render() {
const { activeItem } = this.state; const { activeItem } = this.state;
return ( return (
<Menu color="blue" pointing secondary> <div>
<Image as="a" size="small" src="/assets/img/logo.png" href="/" /> { this.props.user.data.is_staff && this.props.user.data.company && (
<Menu.Menu position="right"> <div className="admin-bar">
<Menu.Item as={Link} to="/home" name="home" active={activeItem === 'home'} onClick={this.handleItemClick} /> Anda login sebagai perusahaan: {this.props.user.data.company.name} (#{this.props.user.data.company.id}).
<Menu.Item as={Link} to="/profile" name="profil" active={activeItem === 'profil'} onClick={this.handleItemClick} /> Untuk keluar, silahkan klik <a href="#" onClick={this.logoutCompany}> link ini</a>
<Menu.Item as={Link} onClick={this.logout} name="logout" /> </div>
</Menu.Menu> )}
</Menu> <Menu color="blue" pointing secondary>
<Image as="a" size="small" src="/assets/img/logo.png" href="/" />
<Menu.Menu position="right">
<Menu.Item as={Link} to="/home" name="home" active={activeItem === 'home'} onClick={this.handleItemClick} />
<Menu.Item as={Link} to="/profile" name="profil" active={activeItem === 'profil'} onClick={this.handleItemClick} />
<Menu.Item as={Link} onClick={this.logout} name="logout" />
</Menu.Menu>
</Menu>
</div>
); );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment