Fakultas Ilmu Komputer UI

Commit 8340f8f4 authored by sirinbaisa's avatar sirinbaisa
Browse files

[#22] [#140652771] page profil

parent 18f64d25
......@@ -219,3 +219,4 @@ card .formRegis{
margin-left: 10%;
margin-right: 10%;
}
import React from 'react';
import TopMenu from './components/TopMenu';
import Server from './lib/Server';
const defaultPicture = 'http://semantic-ui.com/images/avatar/small/elliot.jpg';
export default class Dashboard extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired,
route: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.node),
React.PropTypes.node,
]).isRequired,
};
constructor(props) {
super(props);
/* istanbul ignore next */
this.state = {
id: '',
name: '',
email: '',
photo: '',
};
this.getProfile = this.getProfile.bind(this);
this.getProfile();
}
getProfile() {
const id = this.props.route.own ? this.props.user.data.student.id : this.props.params.id;
return Server.get(`/students/${id}/`).then((data) => {
this.setState({
id: data.id,
name: data.name,
email: data.user.email,
photo: data.photo,
});
}, error => error.then(() => {
// this.modalAlert.open('Gagal Mengambil ', r.error);
this.state.name = 'Gagal mendapatkan informasi';
}));
}
render = () => (
<div>
<TopMenu />
<TopMenu
name={this.state.name} email={this.state.email}
photo={this.state.photo ? this.state.photo : defaultPicture}
/>
{this.props.children}
</div>
)
......
import React from 'react';
import { Menu, Image } from 'semantic-ui-react';
import { Menu, Image, Popup, Button, Card } from 'semantic-ui-react';
import { Link, browserHistory } from 'react-router';
import Server from '../lib/Server';
import Storage from '../lib/Storage';
export default class TopMenu extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired,
name: React.PropTypes.string.isRequired,
email: React.PropTypes.string.isRequired,
photo: React.PropTypes.any.isRequired,
};
constructor(props) {
super(props);
/* istanbul ignore next */
console.log(this.props.user);
this.state = { activeItem: 'home' };
this.logout = this.logout.bind(this);
}
......@@ -25,13 +32,31 @@ export default class TopMenu extends React.Component {
render() {
const { activeItem } = this.state;
return (
<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.Item>
<Popup
trigger={<Image
as={Link} to="/profil" src={this.props.photo} avatar
onClick={this.handleItemClick}
/>}
flowing
hoverable
>
<Card
header={this.props.name}
description={this.props.email}
/>
<Button as={Link} onClick={this.logout} name="logout" color="blue" size="tiny">Logout</Button>
</Popup>
</Menu.Item>
</Menu.Menu>
</Menu>
);
......
......@@ -91,7 +91,7 @@ export default class App extends React.Component {
return (
<Router history={browserHistory}>
<Route path="/login" component={Login} />
<Route component={Dashboard} onEnter={this.handleAuth}>
<Route component={App.getRole() === 'student' ? student(Dashboard) : company(Dashboard)} onEnter={this.handleAuth} own>
<Route path="/lowongan" component={commonUser(VacancyPage)} />
<Route path="/buat-lowongan" component={company(CreateVacancy)} />
<Route path="/buat-lowongan/:id" component={company(CreateVacancy)} />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment