mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-01 21:51:48 -05:00
initial commit
This commit is contained in:
43
src/App.jsx
Normal file
43
src/App.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import {
|
||||
HashRouter as Router,
|
||||
Route,
|
||||
Link,
|
||||
Redirect
|
||||
} from 'react-router-dom';
|
||||
|
||||
import api from './api';
|
||||
|
||||
import About from './components/About';
|
||||
import Dashboard from './components/Dashboard';
|
||||
import Login from './components/Login';
|
||||
import Organizations from './components/Organizations';
|
||||
|
||||
const AuthenticatedRoute = ({ component: Component, ...rest }) => (
|
||||
<Route {...rest} render={props => (
|
||||
api.isAuthenticated() ? (
|
||||
<Component {...props}/>
|
||||
) : (
|
||||
<Redirect to={{
|
||||
pathname: '/login',
|
||||
state: { from: props.location }
|
||||
}}/>
|
||||
)
|
||||
)}/>
|
||||
)
|
||||
|
||||
const App = () => (
|
||||
<Router>
|
||||
<div>
|
||||
<Route path="/login" component={Login} />
|
||||
<AuthenticatedRoute exact path="/" component={Dashboard} />
|
||||
<AuthenticatedRoute exact path="/about" component={About} />
|
||||
<AuthenticatedRoute exact path="/organizations" component={Organizations} />
|
||||
</div>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const el = document.getElementById('app');
|
||||
|
||||
render(<App />, el);
|
||||
Reference in New Issue
Block a user