refactor: edit routes

This commit is contained in:
frab1t 2019-05-18 13:45:22 +02:00
parent 5d5e85a6c6
commit eec2b646cf
2 changed files with 49 additions and 22 deletions

View File

@ -5,34 +5,15 @@ import { Container } from 'reactstrap';
import './App.css'; import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css'; import 'bootstrap/dist/css/bootstrap.min.css';
import Routes from './Routes';
import NavBar from './components/NavBar'; import NavBar from './components/NavBar';
import Home from './containers/HomePage/Home';
import CreateTicket from './containers/CreateTicket/CreateTicket';
import ViewRequest from './containers/ViewTicket/ViewTicket';
import PageNotFound from './containers/PageNotFound';
import Login from './containers/Administration/Login';
import TicketList from './containers/Administration/TicketList';
import TicketWork from './containers/Administration/TicketManager';
function App() { function App() {
return ( return (
<div className="app"> <div className="app">
<Router> <Routes>
<NavBar /> <NavBar />
<Container> </Routes>
<Switch>
<Route path="/" exact component={Home} />
<Route path="/create" component={CreateTicket} />
<Route path="/ticket/:ticketId" component={ViewRequest} />
<Route path="/ticket/" exact component={ () => <Redirect to="/" /> } />
<Route path="/login" component={Login} />
<Route path="/admin/" exact component={ () => <Redirect to="/admin/ticket" /> } />
<Route path="/admin/ticket" exact component={TicketList} />
<Route path="/admin/ticket/:ticketId" component={TicketWork} />
<Route component={PageNotFound} />
</Switch>
</Container>
</Router>
</div> </div>
); );
} }

46
src/Routes.js Normal file
View File

@ -0,0 +1,46 @@
import React, { Component } from 'react';
import {
Container
} from 'reactstrap';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import Home from './containers/HomePage/Home';
import CreateTicket from './containers/CreateTicket/CreateTicket';
import ViewRequest from './containers/ViewTicket/ViewTicket';
import PageNotFound from './containers/PageNotFound';
import Login from './containers/Administration/Login';
import TicketList from './containers/Administration/TicketList';
import TicketWork from './containers/Administration/TicketManager';
class Routes extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<Router>
{this.props.children}
<Container>
<Switch>
<Route path="/" exact component={Home} />
<Route path="/create" component={CreateTicket} />
<Route path="/ticket/:ticketId" component={ViewRequest} />
<Route path="/ticket/" exact component={() => <Redirect to="/" />} />
<Route path="/login" component={Login} />
<Route path="/admin/" exact component={() => <Redirect to="/admin/ticket" />} />
<Route path="/admin/ticket" exact component={TicketList} />
<Route path="/admin/ticket/:ticketId" component={TicketWork} />
<Route component={PageNotFound} />
</Switch>
</Container>
</Router>
);
}
}
export default Routes;