router.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React, { Component, Fragment } from "react";
  2. import { Switch, Route, withRouter } from "react-router-dom";
  3. import { connect } from 'react-redux';
  4. import { bindActionCreators } from "redux";
  5. import MainPage from "./container/MainPage";
  6. import RenderAuthorisation from "./container/renderAuthorisation"
  7. import RenderRegistration from "./container/renderRegistration"
  8. import CategoryStaffInfo from './container/CategoryStaffInfo'
  9. import MainPageStaffInfo from './container/MainPageStaffInfo'
  10. import SearchStaffs from './container/SearchStaff'
  11. import SearchStaffsInfo from './container/SearchStaffsInfo'
  12. import AddNewStaff from './container/AddNewStaff'
  13. import AddNewCategory from './container/AddNewCategory'
  14. import ActiveStaffs from './container/activeStaffs'
  15. import redactorForm from './container/redactorForm'
  16. // import Form from './components/Auth/index'
  17. // import RegistrForm from './components/Auth/registration'
  18. // import UserProtect from './components/usersProtectPage/'
  19. // import UserProfile from './components/Header/Myprofile'
  20. import PrivateRoute from './components/usersProtectPage/PrivateRoute'
  21. import userProfile from './container/UserProfile'
  22. import { getUsersDataById } from "./actions/getUserById"
  23. import { getUsersData } from './actions/usersAuthActions'
  24. import addCategory from './components/privateRouterComponents/addCategoryIfAdmin'
  25. class Router extends Component {
  26. render() {
  27. const { inputData, trig, params} = this.props
  28. return (
  29. <div>
  30. <Switch>
  31. <PrivateRoute path="/" data= { inputData } params = {params} exact component={MainPage} />
  32. {/* <Route path="/" exact component={MainPage} /> */}
  33. <Route path="/user/:id" exact component={userProfile} />
  34. <Route path="/authorisation" exact component={RenderAuthorisation} />
  35. <Route path="/auth" exact component= {RenderAuthorisation}/>
  36. <Route path="/registration" exact component={RenderRegistration} />
  37. <Route path="/category/staff/:id" exact component={CategoryStaffInfo} />
  38. <Route path="/staff/:id" exact component={MainPageStaffInfo} />
  39. <Route path="/search/:title" exact component={SearchStaffs} />
  40. <Route path="/search/Staff/:id" exact component={SearchStaffsInfo} />
  41. <Route path="/newStaff" exact component={AddNewStaff} />
  42. <Route path="/addCategory" exact component={AddNewCategory} />
  43. <Route path="/activeStaffs" exact component={ ActiveStaffs } />
  44. <Route path="/activeStaffs/:id" exact component={ redactorForm } />
  45. </Switch>
  46. </div>
  47. )
  48. }
  49. }
  50. const mapStateToProps = state => ({
  51. inputData: state.usersAuth.inputData,
  52. trig: state.usersAuth.trig,
  53. params: state.getUserById.params,
  54. })
  55. const mapDispatchToProps = dispatch => bindActionCreators({ getUsersData, getUsersDataById }, dispatch);
  56. export default withRouter(connect(
  57. mapStateToProps,
  58. mapDispatchToProps
  59. )(Router));