Fakultas Ilmu Komputer UI

Index.jsx 1.6 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
11
12
13
14
15
16
17

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


18
19
20
21
22
23
export default class App extends React.Component {

  constructor(props) {
    super(props);
    /* istanbul ignore next */
    this.handleAuth = this.handleAuth.bind(this);
Zamil Majdy's avatar
Zamil Majdy committed
24
    this.handleHome = this.handleHome.bind(this);
25
26
27
28
29
30
  }

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

Zamil Majdy's avatar
Zamil Majdy committed
31
32
33
34
  handleHome= (nextState, replace) => (
    Server.isLoggedIn() ? replace({ pathname: '/lowongan' }) : replace({ pathname: '/login' })
  );

35
36
37
38
39
40
41

  render = () => (
    <Router history={browserHistory}>
      <Route path="/login" component={Login} />
      <Route path="/register" component={CompanyRegister} />
      <Route component={Dashboard} onEnter={this.handleAuth}>
        <Route path="/" component={Profile} />
42
43
44
        <Route path="/profile" component={Profile} />
        <Route path="/lowongan" component={VacancyPage} />
        <Route path="/users" component={Profile} />
45
      </Route>
Zamil Majdy's avatar
Zamil Majdy committed
46
47
      <Route path="/home" onEnter={this.handleHome} />
      <Redirect from="*" to="/home" />
48
49
50
    </Router>
  );
}
51
52

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