Fakultas Ilmu Komputer UI

Commit a15a59a2 authored by sirinbaisa's avatar sirinbaisa
Browse files

no message

parent bb69e6b3
...@@ -33,14 +33,14 @@ export default class VacancyPage extends React.Component { ...@@ -33,14 +33,14 @@ export default class VacancyPage extends React.Component {
if (this.props.user.role === 'student') { if (this.props.user.role === 'student') {
return ( return (
<Tabs selected={0}> <Tabs selected={0}>
<Pane label="Semua Lowongan" > <Pane label="Semua Lowongan">
<VacancyList <VacancyList
key={1} key={1}
userId={this.state.id} userId={this.state.id}
url="/vacancies/" url="/vacancies/"
/> />
</Pane> </Pane>
<Pane label="Lamaran saya" > <Pane label="Lamaran saya">
<VacancyList <VacancyList
key={2} key={2}
userId={this.state.id} userId={this.state.id}
...@@ -48,7 +48,7 @@ export default class VacancyPage extends React.Component { ...@@ -48,7 +48,7 @@ export default class VacancyPage extends React.Component {
url={`/students/${this.state.id}/applied-vacancies/`} url={`/students/${this.state.id}/applied-vacancies/`}
/> />
</Pane> </Pane>
<Pane label="Lamaran Ditandai" > <Pane label="Lamaran Ditandai">
<VacancyList <VacancyList
key={3} key={3}
userId={this.state.id} userId={this.state.id}
...@@ -59,7 +59,10 @@ export default class VacancyPage extends React.Component { ...@@ -59,7 +59,10 @@ export default class VacancyPage extends React.Component {
); );
} else if (this.props.user.role === 'company' || this.props.user.role === 'admin') { } else if (this.props.user.role === 'company' || this.props.user.role === 'admin') {
return ( return (
<VacancyList key={1} userId={this.state.id} url={`/companies/${this.state.id}/vacancies/`} type="company" /> <VacancyList
key={1} userId={this.state.id} url={`/companies/${this.state.id}/vacancies/`}
type="company"
/>
); );
return ( return (
...@@ -71,6 +74,7 @@ export default class VacancyPage extends React.Component { ...@@ -71,6 +74,7 @@ export default class VacancyPage extends React.Component {
</div> </div>
); );
} }
}
render() { render() {
return ( return (
......
import React from 'react'; 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 { Link, browserHistory } from 'react-router';
import Server from '../lib/Server'; import Server from '../lib/Server';
import Storage from '../lib/Storage'; import Storage from '../lib/Storage';
export default class TopMenu extends React.Component { export default class TopMenu extends React.Component {
static propTypes = { static propTypes = {
user: React.PropTypes.object.isRequired, // user: React.PropTypes.object.isRequired,
name: React.PropTypes.string.isRequired,
email: React.PropTypes.string.isRequired,
photo: React.PropTypes.any.isRequired,
}; };
constructor(props) { constructor(props) {
super(props); super(props);
/* istanbul ignore next */ /* istanbul ignore next */
// console.log(this.props.user);
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 = (e) => { logout = () => {
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 (
<div>
{ this.props.user.data.is_staff && this.props.user.data.company && (
<div className="admin-bar">
Anda login sebagai perusahaan: {this.props.user.data.company.name} (#{this.props.user.data.company.id}).
Untuk keluar, silahkan klik <a href="#" onClick={this.logoutCompany}> link ini</a>
</div>
)}
<Menu color="blue" pointing secondary> <Menu color="blue" pointing secondary>
<Image as="a" size="small" src="/assets/img/logo.png" href="/" /> <Image as="a" size="small" src="/assets/img/logo.png" href="/" />
<Menu.Menu position="right"> <Menu.Menu position="right">
<Menu.Item as={Link} to="/home" name="home" active={activeItem === 'home'} onClick={this.handleItemClick} /> <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} to="/profil" name="profile" 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.Menu>
</Menu> </Menu>
</div>
); );
} }
} }
...@@ -5,14 +5,14 @@ import Dashboard from './Dashboard'; ...@@ -5,14 +5,14 @@ import Dashboard from './Dashboard';
import Login from './Login'; import Login from './Login';
import VacancyPage from './VacancyPage'; import VacancyPage from './VacancyPage';
import ProfilePage from './ProfilePage'; import ProfilePage from './ProfilePage';
import CompanyPage from './CompanyPage';
import CompanyProfile from './CompanyProfile'; import CompanyProfile from './CompanyProfile';
import CreateVacancy from './CreateVacancy'; import CreateVacancy from './CreateVacancy';
import Server from './lib/Server'; import Server from './lib/Server';
import Storage from './lib/Storage'; import Storage from './lib/Storage';
import ApplicantPage from './ApplicantPage'; import ApplicantPage from './ApplicantPage';
import TranscriptPage from './TranscriptPage'; import TranscriptPage from './TranscriptPage';
import AdminVacancyPage from './AdminVacancyPage';
import HomeSupervisor from './HomeSupervisor';
export default class App extends React.Component { export default class App extends React.Component {
static getRole() { static getRole() {
...@@ -74,35 +74,34 @@ export default class App extends React.Component { ...@@ -74,35 +74,34 @@ export default class App extends React.Component {
replace({ pathname: '/lowongan' }); cb(); replace({ pathname: '/lowongan' }); cb();
} else if (App.getRole() === 'company') { } else if (App.getRole() === 'company') {
replace({ pathname: '/lowongan' }); cb(); replace({ pathname: '/lowongan' }); cb();
} else if (App.getRole() === 'admin') {
replace({ pathname: '/perusahaan' }); cb();
} }
} }
replace({ pathname: '/login' }); cb(); replace({ pathname: '/login' }); cb();
}; };
render() { render() {
const staff = this.authorization(['admin']);
const student = this.authorization(['admin', 'student']); const student = this.authorization(['admin', 'student']);
// const supervisor = this.authorization(['admin', 'supervisor']); // const supervisor = this.authorization(['admin', 'supervisor']);
const company = this.authorization(['admin', 'company']); const company = this.authorization(['admin', 'company']);
const commonUser = this.authorization(['admin', 'student', 'company']); const commonUser = this.authorization(['admin', 'student', 'company']);
const grownups = this.authorization(['admin', 'company', 'supervisor']); const grownups = this.authorization(['admin', 'company', 'supervisor']);
const facultyMember = this.authorization(['admin', 'student', 'supervisor']); const facultyMember = this.authorization(['admin', 'student', 'supervisor']);
const all = this.authorization(['admin', 'company', 'student', 'supervisor']);
return ( return (
<Router history={browserHistory}> <Router history={browserHistory}>
<Route path="/login" component={Login} /> <Route path="/login" component={Login} />
<Route component={commonUser(Dashboard)} onEnter={this.handleAuth}> <Route component={all(Dashboard)} onEnter={this.handleAuth} own>
<Route path="/transcript/:id" component={company(TranscriptPage)} /> <Route path="/transcript/:id" component={company(TranscriptPage)} />
<Route path="/lowongan" component={commonUser(VacancyPage)} /> <Route path="/lowongan" component={commonUser(VacancyPage)} />
<Route path="/admin-lowongan" component={AdminVacancyPage} />
<Route path="/buat-lowongan" component={company(CreateVacancy)} /> <Route path="/buat-lowongan" component={company(CreateVacancy)} />
<Route path="/buat-lowongan/:id" component={company(CreateVacancy)} /> <Route path="/buat-lowongan/:id" component={company(CreateVacancy)} />
<Route path="/pelamar" component={company(ApplicantPage)} /> <Route path="/pelamar" component={company(ApplicantPage)} />
<Route path="/profil" component={App.getRole() === 'student' ? student(ProfilePage) : company(CompanyProfile)} own /> <Route path="/profil" component={App.getRole() === 'student' ? student(ProfilePage) : company(CompanyProfile)} own />
<Route path="/mahasiswa/:id" component={grownups(ProfilePage)} /> <Route path="/mahasiswa/:id" component={grownups(ProfilePage)} />
<Route path="/perusahaan/:id" component={facultyMember(CompanyProfile)} /> <Route path="/perusahaan/:id" component={facultyMember(CompanyProfile)} />
<Route path="/perusahaan" component={staff(CompanyPage)} /> <Route path="/home-supervisor" component={HomeSupervisor} />
<Route path="/transkrip/:id" component={facultyMember(CompanyProfile)} /> <Route path="/transkrip/:id" component={facultyMember(CompanyProfile)} />
</Route> </Route>
<Route path="/home" onEnter={this.handleHome} /> <Route path="/home" onEnter={this.handleHome} />
......
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