-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(): update all dependencies to either latest or 1 major version …
…below
- Loading branch information
Showing
26 changed files
with
5,835 additions
and
4,869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import React from "react"; | ||
import { Route, RouteProps } from "react-router-dom"; | ||
import React, { useContext } from "react"; | ||
import { useLocation, Outlet, Navigate } from "react-router-dom"; | ||
import { UserContext } from "../../contexts/UserContext/UserContext"; | ||
import Login from "../../pages/Login/Login"; | ||
|
||
const ProtectedRoute: React.FC<RouteProps> = ({ children, ...props }) => { | ||
const ProtectedRoute: React.FC = () => { | ||
const { | ||
state: { loggedIn }, | ||
} = React.useContext(UserContext); | ||
} = useContext(UserContext); | ||
const location = useLocation(); | ||
|
||
if (!loggedIn) return <Route {...props} component={Login} />; | ||
|
||
return <Route {...props}>{children}</Route>; | ||
return loggedIn ? <Outlet /> : <Navigate to="/login" state={{ from: location }} replace />; | ||
}; | ||
|
||
export default ProtectedRoute; |
Oops, something went wrong.