|
@@ -1,37 +1,65 @@
|
|
|
-import React from "react";
|
|
|
-import { Switch, Route } from "react-router-dom";
|
|
|
+import React, { Component, Fragment } from "react";
|
|
|
+import { Switch, Route, withRouter } from "react-router-dom";
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { bindActionCreators } from "redux";
|
|
|
|
|
|
-import RenderRegistration from "./container/renderRegistration"
|
|
|
-import RenderAuthorisation from "./container/renderAuthorisation"
|
|
|
+import PrivateRoute from './components/usersProtectPage/PrivateRoute'
|
|
|
+
|
|
|
+import { getUsersDataById } from "./actions/getUserById"
|
|
|
+import { getUsersData } from './actions/usersAuthActions'
|
|
|
|
|
|
import MainPage from "./container/MainPage";
|
|
|
-// import Form from './components/Auth/index'
|
|
|
-// import RegistrForm from './components/Auth/registration'
|
|
|
-import MainPageStaffInfo from './container/MainPageStaffInfo'
|
|
|
+import userProfile from './container/UserProfile'
|
|
|
+import RenderAuthorisation from "./container/renderAuthorisation"
|
|
|
+import RenderRegistration from "./container/renderRegistration"
|
|
|
import CategoryStaffInfo from './container/CategoryStaffInfo'
|
|
|
-
|
|
|
+import MainPageStaffInfo from './container/MainPageStaffInfo'
|
|
|
import SearchStaffs from './container/SearchStaff'
|
|
|
-
|
|
|
import SearchStaffsInfo from './container/SearchStaffsInfo'
|
|
|
import AddNewStaff from './container/AddNewStaff'
|
|
|
-
|
|
|
import AddNewCategory from './container/AddNewCategory'
|
|
|
|
|
|
-export default () => (
|
|
|
-
|
|
|
- <div>
|
|
|
- <Switch>
|
|
|
- <Route path="/" exact component={MainPage} />
|
|
|
- <Route path="/authorisation" exact component={RenderAuthorisation} />
|
|
|
- <Route path="/auth" exact component= {RenderAuthorisation}/>
|
|
|
- <Route path="/registration" exact component={RenderRegistration} />
|
|
|
- <Route path="/category/staff/:id" exact component={CategoryStaffInfo} />
|
|
|
- <Route path="/staff/:id" exact component={MainPageStaffInfo} />
|
|
|
- <Route path="/search/:title" exact component={SearchStaffs} />
|
|
|
- <Route path="/search/Staff/:id" exact component={SearchStaffsInfo} />
|
|
|
- <Route path="/newStaff" exact component={AddNewStaff} />
|
|
|
- <Route path="/addCategory" exact component={AddNewCategory} />
|
|
|
- </Switch>
|
|
|
- </div>
|
|
|
-);
|
|
|
+// import Form from './components/Auth/index'
|
|
|
+// import RegistrForm from './components/Auth/registration'
|
|
|
+// import UserProtect from './components/usersProtectPage/'
|
|
|
+// import UserProfile from './components/Header/Myprofile'
|
|
|
+//import addCategory from './components/privateRouterComponents/addCategoryIfAdmin'
|
|
|
+
|
|
|
+class Router extends Component {
|
|
|
+ render() {
|
|
|
+
|
|
|
+ const { inputData, params } = this.props
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Fragment>
|
|
|
+ <Switch>
|
|
|
+ <PrivateRoute path="/" data={inputData} params={params} exact component={MainPage} />
|
|
|
+ {/* <Route path="/" 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} />
|
|
|
+ <Route path="/category/staff/:id" exact component={CategoryStaffInfo} />
|
|
|
+ <Route path="/staff/:id" exact component={MainPageStaffInfo} />
|
|
|
+ <Route path="/search/:title" exact component={SearchStaffs} />
|
|
|
+ <Route path="/search/Staff/:id" exact component={SearchStaffsInfo} />
|
|
|
+ <Route path="/newStaff" exact component={AddNewStaff} />
|
|
|
+ <Route path="/addCategory" exact component={AddNewCategory} />
|
|
|
+ </Switch>
|
|
|
+ </Fragment>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+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));
|
|
|
|