Fakultas Ilmu Komputer UI

Commit 6b5494e7 authored by Arga Ghulam Ahmad's avatar Arga Ghulam Ahmad
Browse files

Set up the route to feedback page

parent aa9b2280
Pipeline #23915 passed with stages
in 7 minutes and 28 seconds
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, Redirect } from 'react-router';
import {
Router, Route, browserHistory, Redirect,
} from 'react-router';
import Dashboard from './Dashboard';
import Login from './Login';
import VacancyPage from './VacancyPage';
......@@ -14,19 +16,19 @@ import TranscriptPage from './TranscriptPage';
import AdminVacancyPage from './AdminVacancyPage';
import CompanyPage from './CompanyPage';
import SupervisorPage from './SupervisorPage';
import FeedbackPage from './FeedbackPage';
export default class App extends React.Component {
static getRole() {
if (Server.isLoggedIn()) {
const data = Storage.get('user-data');
if (data.is_staff) {
return 'admin';
} else if (data.supervisor) {
} if (data.supervisor) {
return 'supervisor';
} else if (data.student) {
} if (data.student) {
return 'student';
} else if (data.company) {
} if (data.company) {
return 'company';
}
return 'error';
......@@ -41,29 +43,34 @@ export default class App extends React.Component {
this.handleHome = this.handleHome.bind(this);
}
authorization = allowedRoles =>
WrappedComponent => (
/* eslint-disable no-multi-comp */
class WithAuthorization extends React.Component {
constructor(props) {
super(props);
this.state = {
user: {
role: App.getRole(),
data: Storage.get('user-data'),
},
};
}
authorization = (allowedRoles) => (WrappedComponent) => (
/* eslint-disable no-multi-comp */
class WithAuthorization extends React.Component {
constructor(props) {
super(props);
this.state = {
user: {
role: App.getRole(),
data: Storage.get('user-data'),
},
};
}
render() {
const { role } = this.state.user;
// const props = this.props;
if (allowedRoles.includes(role)) {
return <WrappedComponent {...this.props} {...this.state} />;
}
return <div> { browserHistory.push('/home') } </div>;
render() {
const { role } = this.state.user;
// const props = this.props;
if (allowedRoles.includes(role)) {
return <WrappedComponent {...this.props} {...this.state} />;
}
});
return (
<div>
{' '}
{ browserHistory.push('/home') }
{' '}
</div>
);
}
});
handleAuth = (nextState, replace) => {
if (!Server.isLoggedIn()) replace({ pathname: '/login' });
......@@ -111,6 +118,7 @@ export default class App extends React.Component {
<Route path="/pelamar" component={company(ApplicantPage)} />
<Route path="/profil-mahasiswa" component={student(ProfilePage)} own />
<Route path="/profil-perusahaan" component={company(CompanyProfile)} />
<Route path="/feedback" component={all(FeedbackPage)} />
<Route path="/mahasiswa/:id" component={grownups(ProfilePage)} />
<Route path="/perusahaan/:id" component={facultyMember(CompanyProfile)} />
<Route path="/perusahaan" component={staff(CompanyPage)} />
......
Markdown is supported
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