Fakultas Ilmu Komputer UI

Index.jsx 1.44 KB
Newer Older
1
2
import React from 'react';
import ReactDOM from 'react-dom';
3
4
import { Router, Route, browserHistory, Redirect } from 'react-router';
import { Segment } from 'semantic-ui-react';
5
6
import Dashboard from './Dashboard';
import Login from './Login';
7
import VacancyPage from './VacancyPage';
8
import CompanyRegister from './CompanyRegister';
9
import Server from './lib/Server';
10
// import Register from './CompanyRegister'
11
12
13
14
15
16
17
18

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


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export default class App extends React.Component {

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

  handleAuth = (nextState, replace) => (
    Server.isLoggedIn() || 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} />
38
39
40
        <Route path="/profile" component={Profile} />
        <Route path="/lowongan" component={VacancyPage} />
        <Route path="/users" component={Profile} />
41
      </Route>
42
      <Redirect from="*" to={Server.isLoggedIn() ? '/lowongan' : '/login'} />
43
44
45
    </Router>
  );
}
46
47

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