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.
 
 

67 lines
2.0 KiB

  1. // project import
  2. import LoginRoutes from './LoginRoutes'
  3. // import MainRoutes from './MainRoutes'
  4. import PublicUserRoutes from './PublicUserRoutes'
  5. import GLDUserRoutes from './GLDUserRoutes'
  6. import TestRoutes from './_TestRoutes'
  7. import { useRoutes } from 'react-router-dom'
  8. import {
  9. isUserLoggedIn,
  10. // isAdminLoggedIn,
  11. isGLDLoggedIn,
  12. isINDLoggedIn,
  13. isORGLoggedIn,
  14. } from "utils/Utils";
  15. import { Navigate } from "react-router";
  16. import {
  17. SetupAxiosInterceptors,
  18. } from "auth/index";
  19. import SettingRoutes from './SettingRoutes';
  20. import AfterLoginRoutes from './AfterLoginRoutes';
  21. // ==============================|| ROUTING RENDER ||============================== //
  22. export default function ThemeRoutes() {
  23. if (isUserLoggedIn()) {
  24. //auto logout if token not valid
  25. SetupAxiosInterceptors();
  26. }
  27. // console.log();
  28. return useRoutes([{
  29. path: '',
  30. children: [
  31. (isUserLoggedIn() ?
  32. {
  33. path: '',
  34. element: <Navigate to="/dashboard" />
  35. }
  36. :
  37. {
  38. path: '',
  39. element: <Navigate to="/login" />
  40. })
  41. ]
  42. },
  43. // isUserLoggedIn() ? MainRoutes : LoginRoutes,
  44. isUserLoggedIn() ? AfterLoginRoutes :
  45. {
  46. path: '/dashboard',
  47. element: <Navigate to="/login" />
  48. },
  49. isUserLoggedIn() && isINDLoggedIn() || isUserLoggedIn() && isORGLoggedIn() ? PublicUserRoutes : LoginRoutes,
  50. isUserLoggedIn() && isGLDLoggedIn() ? SettingRoutes : LoginRoutes,
  51. isUserLoggedIn() && isGLDLoggedIn() ? GLDUserRoutes : LoginRoutes,
  52. !isUserLoggedIn() ? {
  53. path: '*',
  54. element: <Navigate to="/login" />
  55. } :
  56. {
  57. path: '*',
  58. element: <Navigate to="/dashboard" />
  59. },
  60. isUserLoggedIn() && isGLDLoggedIn() && JSON.parse(localStorage.getItem('userData')).fullenName == "2fi" ? TestRoutes : {},
  61. ]);
  62. }