|
@@ -1,5 +1,8 @@
|
|
|
-import React from "react";
|
|
|
-import { Switch, Route } from "react-router-dom";
|
|
|
+import React, {Component} from "react";
|
|
|
+import { Switch, Route, Redirect, withRouter } from "react-router-dom";
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { bindActionCreators } from "redux";
|
|
|
+
|
|
|
|
|
|
import RenderRegistration from "./container/renderRegistration"
|
|
|
import RenderAuthorisation from "./container/renderAuthorisation"
|
|
@@ -17,11 +20,31 @@ import AddNewStaff from './container/AddNewStaff'
|
|
|
|
|
|
import AddNewCategory from './container/AddNewCategory'
|
|
|
|
|
|
-export default () => (
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import PrivateRoute from './components/usersProtectPage/PrivateRoute'
|
|
|
+
|
|
|
+import userProfile from './container/UserProfile'
|
|
|
+
|
|
|
+import { getUsersDataById } from "./actions/getUserById"
|
|
|
|
|
|
+import { getUsersData } from './actions/usersAuthActions'
|
|
|
+
|
|
|
+import addCategory from './components/privateRouterComponents/addCategoryIfAdmin'
|
|
|
+
|
|
|
+class Router extends Component{
|
|
|
+ render() {
|
|
|
+
|
|
|
+ const { inputData, trig, params} = this.props
|
|
|
+ console.log(this.props)
|
|
|
+ return (
|
|
|
<div>
|
|
|
<Switch>
|
|
|
- <Route path="/" exact component={MainPage} />
|
|
|
+ <PrivateRoute path="/" data= { inputData } params = {params} exact component={MainPage} />
|
|
|
+ {}
|
|
|
+ <Route path="/user/:id" exact component={userProfile} />
|
|
|
<Route path="/authorisation" exact component={RenderAuthorisation} />
|
|
|
<Route path="/auth" exact component= {RenderAuthorisation}/>
|
|
|
<Route path="/registration" exact component={RenderRegistration} />
|
|
@@ -33,5 +56,16 @@ export default () => (
|
|
|
<Route path="/addCategory" exact component={AddNewCategory} />
|
|
|
</Switch>
|
|
|
</div>
|
|
|
-);
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mapStateToProps = state => ({
|
|
|
+ inputData: state.usersAuth.inputData,
|
|
|
+ trig: state.usersAuth.trig,
|
|
|
+ params: state.getUserById.params,
|
|
|
+})
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({ getUsersData, getUsersDataById }, dispatch);
|
|
|
+
|
|
|
+export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Router));
|
|
|
|