Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6738 | Rev 6745 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6601 stevensc 1
import React, { lazy, Suspense, useEffect } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
6514 stevensc 3
import { BrowserRouter as Router, Switch } from 'react-router-dom'
6490 stevensc 4
import { getLanguage } from '../../redux/intl/intl.action'
5
 
6530 stevensc 6
import PublicRoute from './PublicRoute'
6601 stevensc 7
import PrivateRoute from './PrivateRoute'
6707 stevensc 8
import Spinner from '../components/UI/Spinner'
6512 stevensc 9
import NotificationAlert from '../components/UI/notification/NotificationAlert'
6738 stevensc 10
import LoaderContainer from '../components/UI/LoaderContainer'
6490 stevensc 11
 
6707 stevensc 12
const Header = lazy(() => import('../components/navbar/Header'))
6601 stevensc 13
const Auth = lazy(() => import('../pages/auth/Auth'))
14
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
6707 stevensc 15
const MyConnectionsPage = lazy(() =>
6719 stevensc 16
  import('../pages/connections/MyConnectionsPage')
6707 stevensc 17
)
6724 stevensc 18
const InvitationsReceivedPage = lazy(() =>
19
  import('../pages/connections/InvitationsReceivedPage')
20
)
6719 stevensc 21
const InvitationsSendPage = lazy(() =>
6724 stevensc 22
  import('../pages/connections/InvitationsSendPage')
6719 stevensc 23
)
6725 stevensc 24
const PeopleYouMayKnowPage = lazy(() =>
25
  import('../pages/connections/PeopleYouMayKnowPage')
26
)
27
const PeopleBlockedPage = lazy(() =>
28
  import('../pages/connections/PeopleBlockedPage')
29
)
6738 stevensc 30
const MyProfilesPage = lazy(() => import('../pages/profiles/MyProfilesPage'))
31
const PeopleViewedMyProfilePage = lazy(() =>
32
  import('../pages/profiles/PeopleViewedMyProfilePage')
33
)
34
const SavedJobsPage = lazy(() => import('../pages/jobs/SavedJobsPage'))
35
const AppliedJobsPage = lazy(() => import('../pages/jobs/AppliedJobsPage'))
36
const GroupsRequestsSendPage = lazy(() =>
37
  import('../pages/groups/GroupsRequestsSendPage')
38
)
39
const GroupsRequestsReceivedPage = lazy(() =>
40
  import('../pages/groups/GroupsRequestsReceivedPage')
41
)
42
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
43
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
6490 stevensc 44
 
45
const AppRouter = () => {
6601 stevensc 46
  const { isAuth } = useSelector(({ auth }) => auth)
6490 stevensc 47
  const dispatch = useDispatch()
48
 
49
  useEffect(() => {
50
    dispatch(getLanguage())
51
  }, [])
52
 
53
  return (
54
    <Router>
6724 stevensc 55
      <Suspense fallback={null}>{isAuth && <Header />}</Suspense>
56
 
6707 stevensc 57
      <Suspense
58
        fallback={
6738 stevensc 59
          <LoaderContainer>
6707 stevensc 60
            <Spinner />
6738 stevensc 61
          </LoaderContainer>
6707 stevensc 62
        }
63
      >
64
        <Switch>
6601 stevensc 65
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
66
            <DashboardPage />
67
          </PrivateRoute>
6738 stevensc 68
 
6707 stevensc 69
          <PrivateRoute
70
            exact
71
            path="/connection/my-connections"
72
            isAuthenticated={isAuth}
73
          >
74
            <MyConnectionsPage />
75
          </PrivateRoute>
6719 stevensc 76
          <PrivateRoute
77
            exact
78
            path="/connection/invitations-sent"
79
            isAuthenticated={isAuth}
80
          >
81
            <InvitationsSendPage />
82
          </PrivateRoute>
6724 stevensc 83
          <PrivateRoute
84
            exact
85
            path="/connection/invitations-received"
86
            isAuthenticated={isAuth}
87
          >
88
            <InvitationsReceivedPage />
89
          </PrivateRoute>
6725 stevensc 90
          <PrivateRoute
91
            exact
92
            path="/connection/people-you-may-know"
93
            isAuthenticated={isAuth}
94
          >
95
            <PeopleYouMayKnowPage />
96
          </PrivateRoute>
97
          <PrivateRoute
98
            exact
6726 stevensc 99
            path="/connection/people-blocked"
6725 stevensc 100
            isAuthenticated={isAuth}
101
          >
102
            <PeopleBlockedPage />
103
          </PrivateRoute>
6738 stevensc 104
 
6727 stevensc 105
          <PrivateRoute
106
            exact
107
            path="/profile/my-profiles"
108
            isAuthenticated={isAuth}
109
          >
110
            <MyProfilesPage />
111
          </PrivateRoute>
112
          <PrivateRoute
113
            exact
114
            path="/profile/people-viewed-profile"
115
            isAuthenticated={isAuth}
116
          >
117
            <PeopleViewedMyProfilePage />
118
          </PrivateRoute>
6738 stevensc 119
 
6727 stevensc 120
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
121
            <SavedJobsPage />
122
          </PrivateRoute>
123
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 124
            <AppliedJobsPage />
6727 stevensc 125
          </PrivateRoute>
6601 stevensc 126
 
6738 stevensc 127
          <PrivateRoute
128
            exact
6740 stevensc 129
            path="/group/requests-sent"
6738 stevensc 130
            isAuthenticated={isAuth}
131
          >
132
            <GroupsRequestsSendPage />
133
          </PrivateRoute>
134
          <PrivateRoute
135
            exact
136
            path="/group/invitations-received"
137
            isAuthenticated={isAuth}
138
          >
139
            <GroupsRequestsReceivedPage />
140
          </PrivateRoute>
141
          <PrivateRoute
142
            exact
143
            path="/group/joined-groups"
144
            isAuthenticated={isAuth}
145
          >
146
            <JoinedGroupsPage />
147
          </PrivateRoute>
148
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
149
            <MyGroupsPage />
150
          </PrivateRoute>
151
 
6601 stevensc 152
          <PublicRoute path="/" isAuthenticated={isAuth}>
6546 stevensc 153
            <Auth />
154
          </PublicRoute>
6707 stevensc 155
        </Switch>
156
      </Suspense>
6512 stevensc 157
 
158
      <NotificationAlert />
6490 stevensc 159
    </Router>
160
  )
161
}
162
 
163
export default AppRouter