You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppRoutes.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import React, { useEffect } from "react";
  2. import { Redirect, Route, Switch } from "react-router-dom";
  3. import { useDispatch } from "react-redux";
  4. import { refreshUserToken } from "./store/actions/login/loginActions";
  5. import { useLocation } from "react-router-dom";
  6. import {
  7. // ADS_PAGE,
  8. // AD_DETAILS_PAGE,
  9. FORGOT_PASSWORD_PAGE,
  10. FORGOT_PASSWORD_CONFIRMATION_PAGE,
  11. NOT_FOUND_PAGE,
  12. ERROR_PAGE,
  13. BASE_PAGE,
  14. RESET_PASSWORD_PAGE,
  15. USERS_PAGE,
  16. // CANDIDATES_PAGE,
  17. USER_DETAILS_PAGE,
  18. // CANDIDATES_DETAILS_PAGE,
  19. // SELECTION_PROCESS_PAGE,
  20. // SELECTION_PROCESS_OF_APPLICANT_PAGE,
  21. // PATTERNS_PAGE,
  22. // PATTERN_DETAILS_PAGE,
  23. // SCHEDULE_PAGE,
  24. // STATS_PAGE,
  25. REGISTER_PAGE,
  26. // CREATE_AD_PAGE,
  27. // FILES_VIEW_PAGE,
  28. ADD_FILE,
  29. FILES_PAGE,
  30. FILES_DEPTH_PAGE
  31. } from "./constants/pages";
  32. import LoginPage from "./pages/LoginPage/LoginPageMUI";
  33. // import AdsPage from "./pages/AdsPage/AdsPage";
  34. import NotFoundPage from "./pages/ErrorPages/NotFoundPage";
  35. import ErrorPage from "./pages/ErrorPages/ErrorPage";
  36. import ForgotPasswordPage from "./pages/ForgotPasswordPage/ForgotPasswordPageMUI";
  37. import PrivateRoute from "./components/Router/PrivateRoute";
  38. import ForgotPasswordConfirmationPage from "./pages/ForgotPasswordPage/ForgotPasswordConfirmationPageMUI";
  39. import ResetPasswordPage from "./pages/ForgotPasswordPage/ResetPasswordPageMUI";
  40. import UsersPage from "./pages/UsersPage/UsersPage";
  41. // import CandidatesPage from "./pages/CandidatesPage/CandidatesPage";
  42. // import AdDetailsPage from "./pages/AdsPage/AdDetailsPage";
  43. import UserDetails from "./pages/UsersPage/UserDetails";
  44. // import CandidateDetailsPage from "./pages/CandidatesPage/CandidateDetailsPage";
  45. // import SelectionProcessPage from "./pages/SelectionProcessPage/SelectionProcessPage";
  46. // import SelectionProcessOfApplicantPage from "./pages/SelectionProcessPage/SelectionProcessOfApplicantPage";
  47. // import PatternsPage from "./pages/PatternsPage/PatternsPage";
  48. // import PatternDetailsPage from "./pages/PatternsPage/PatternDetailsPage";
  49. // import SchedulePage from "./pages/SchedulePage/SchedulePage";
  50. // import StatsPage from "./pages/StatsPage/StatsPage";
  51. import RegisterPage from "./pages/RegisterPage/RegisterPage";
  52. // import CreateAdPage from "./pages/AdsPage/CreateAdPage";
  53. // import FilesViewPage from "./pages/FilesPage/FilesViewPage";
  54. import AddFile from "./pages/FilesPage/AddFile";
  55. import FilesPage from "./pages/FilesPage/FilesPage";
  56. const AppRoutes = () => {
  57. const dispatch = useDispatch();
  58. const location = useLocation();
  59. useEffect(() => {
  60. if (location.pathname === BASE_PAGE) {
  61. return;
  62. }
  63. dispatch(refreshUserToken());
  64. }, [location]);
  65. return (
  66. <Switch>
  67. <Route exact path={BASE_PAGE} component={LoginPage} />
  68. <Route path={NOT_FOUND_PAGE} component={NotFoundPage} />
  69. {/* <Route path={USERS_PAGE} component={UsersPage} /> */}
  70. <Route path={ERROR_PAGE} component={ErrorPage} />
  71. <Route path={FORGOT_PASSWORD_PAGE} component={ForgotPasswordPage} />
  72. <Route
  73. path={FORGOT_PASSWORD_CONFIRMATION_PAGE}
  74. component={ForgotPasswordConfirmationPage}
  75. />
  76. <Route exact path={REGISTER_PAGE} component={RegisterPage} />
  77. <Route path={RESET_PASSWORD_PAGE} component={ResetPasswordPage} />
  78. {/* <PrivateRoute exact path={ADS_PAGE} component={AdsPage} /> */}
  79. {/* <PrivateRoute exact path={AD_DETAILS_PAGE} component={AdDetailsPage} /> */}
  80. <PrivateRoute exact path={USER_DETAILS_PAGE} component={UserDetails} />
  81. <PrivateRoute exact path={USERS_PAGE} component={UsersPage} />
  82. {/* <PrivateRoute exact path={CANDIDATES_PAGE} component={CandidatesPage} />
  83. <PrivateRoute exact path={CREATE_AD_PAGE} component={CreateAdPage} /> */}
  84. {/* <PrivateRoute exact path={FILES_PAGE} component={FilesPage} /> */}
  85. {/* <PrivateRoute exact path={FILES_VIEW_PAGE} component={FilesViewPage} /> */}
  86. <PrivateRoute exact path={ADD_FILE} component={AddFile}/>
  87. <PrivateRoute exact path={FILES_PAGE} component={FilesPage}/>
  88. <PrivateRoute exact path={FILES_DEPTH_PAGE} component={FilesPage}/>
  89. {/* <PrivateRoute
  90. exact
  91. path={CANDIDATES_DETAILS_PAGE}
  92. component={CandidateDetailsPage}
  93. />
  94. <PrivateRoute
  95. exact
  96. path={SELECTION_PROCESS_PAGE}
  97. component={SelectionProcessPage}
  98. />
  99. <PrivateRoute
  100. exact
  101. path={SELECTION_PROCESS_OF_APPLICANT_PAGE}
  102. component={SelectionProcessOfApplicantPage}
  103. />
  104. <PrivateRoute
  105. exact
  106. path={PATTERN_DETAILS_PAGE}
  107. component={PatternDetailsPage}
  108. />
  109. <PrivateRoute exact path={PATTERNS_PAGE} component={PatternsPage} />
  110. <PrivateRoute exact path={SCHEDULE_PAGE} component={SchedulePage} />
  111. <PrivateRoute exact path={STATS_PAGE} component={StatsPage} /> */}
  112. <Redirect from="*" to={NOT_FOUND_PAGE} />
  113. </Switch>
  114. );
  115. };
  116. export default AppRoutes;