fixed routing

feature/appm-store/pbac
Jayasanka 6 years ago
parent b3d87186eb
commit 9a580e513f

@ -3,22 +3,28 @@ import "antd/dist/antd.css";
import RouteWithSubRoutes from "./components/RouteWithSubRoutes";
import {
BrowserRouter as Router,
Link,
Link, Redirect, Switch,
} from 'react-router-dom';
class App extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
console.log(this.routes);
return (
<Router>
<div>
<Switch>
<Redirect exact from="/publisher" to="/publisher/dashboard/apps"/>
{this.routes.map((route) => (
<RouteWithSubRoutes key={route.path} {...route} />
))}
</Switch>
</div>
</Router>

@ -8,7 +8,7 @@ class RouteWithSubRoutes extends React.Component{
}
render() {
return(
<Route path={this.props.path} render={(props) => (
<Route path={this.props.path} exact={this.props.exact} render={(props) => (
<this.props.component {...props} routes={this.props.routes}/>
)}/>
);

@ -9,24 +9,29 @@ import AddNewApp from "./pages/dashboard/add-new-app/AddNewApp";
import './index.css';
import store from "./js/store/index";
import {Provider} from "react-redux";
import {Switch} from "react-router";
const routes = [
{
path: '/publisher/login',
exact: true,
component: Login
},
{
path: '/publisher',
path: '/publisher/dashboard',
exact: false,
component: Dashboard,
routes: [
{
path: '/publisher/apps',
component: Apps
path: '/publisher/dashboard/apps',
component: Apps,
exact: false
},
{
path: '/publisher/new-app',
component: AddNewApp
path: '/publisher/dashboard/new-app',
component: AddNewApp,
exact: false
}
]
}

@ -38,7 +38,7 @@ class Dashboard extends React.Component {
</Header>
<Content style={{padding: '0 0'}}>
<Switch>
<Redirect exact from="/publisher" to="/publisher/apps"/>
<Redirect exact from="/publisher/dashboard" to="/publisher/dashboard/apps"/>
{this.state.routes.map((route) => (
<RouteWithSubRoutes key={route.path} {...route} />
))}

Loading…
Cancel
Save