Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Index.jsx 1.60 KiB
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, Redirect } from 'react-router';
import { Segment } from 'semantic-ui-react';
import Dashboard from './Dashboard';
import Login from './Login';
import VacancyPage from './VacancyPage';
import CompanyRegister from './CompanyRegister';
import Server from './lib/Server';

export const Profile = () => (
  <Segment>
    <img src="http://semantic-ui.com/images/wireframe/media-paragraph.png" alt="wire-frame" />
  </Segment>
);


export default class App extends React.Component {

  constructor(props) {
    super(props);
    /* istanbul ignore next */
    this.handleAuth = this.handleAuth.bind(this);
    this.handleHome = this.handleHome.bind(this);
  }

  handleAuth = (nextState, replace) => (
    Server.isLoggedIn() || replace({ pathname: '/login' })
  );

  handleHome= (nextState, replace) => (
    Server.isLoggedIn() ? replace({ pathname: '/lowongan' }) : replace({ pathname: '/login' })
  );


  render = () => (
    <Router history={browserHistory}>
      <Route path="/login" component={Login} />
      <Route path="/register" component={CompanyRegister} />
      <Route component={Dashboard} onEnter={this.handleAuth}>
        <Route path="/" component={Profile} />
        <Route path="/profile" component={Profile} />
        <Route path="/lowongan" component={VacancyPage} />
        <Route path="/users" component={Profile} />
      </Route>
      <Route path="/home" onEnter={this.handleHome} />
      <Redirect from="*" to="/home" />
    </Router>
  );
}

ReactDOM.render(<App />, document.getElementById('react-app'));