add project structure
This commit is contained in:
1 parent
07fc6c0b6c
commit
6eaf18285a
28 files changed
+1309
-648
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom'
|
||||
|
||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
|
||||
import { LocalStorage } from '@utils/localStorageUtils.ts'
|
||||
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
const PrivateRoute = () => {
|
||||
const location = useLocation()
|
||||
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
|
||||
|
||||
if (!userToken) {
|
||||
LocalStorage.set('redirectUrl', location.pathname)
|
||||
return <Navigate to={routePaths.login} replace />
|
||||
}
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export default PrivateRoute
|
||||
Reference in new issue
Block a user