-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1021 from MTES-MCT/chore-upgrade-react-router
Upgrade react router v5 to v6
- Loading branch information
Showing
48 changed files
with
809 additions
and
763 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { Navigate, useLocation } from 'react-router-dom'; | ||
|
||
import { useUser } from '../../hooks/useUser'; | ||
import { useFetchInterceptor } from '../../hooks/useFetchInterceptor'; | ||
|
||
interface RequireAuthProps {} | ||
|
||
function RequireAuth(props: PropsWithChildren<RequireAuthProps>) { | ||
const { isAuthenticated } = useUser(); | ||
const location = useLocation(); | ||
|
||
useFetchInterceptor(); | ||
|
||
if (isAuthenticated) { | ||
return props.children; | ||
} | ||
|
||
return ( | ||
<Navigate to="/connexion" replace state={{ path: location.pathname }} /> | ||
); | ||
} | ||
|
||
export default RequireAuth; |
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,18 @@ | ||
import { PropsWithChildren } from 'react'; | ||
|
||
import { useUser } from '../../hooks/useUser'; | ||
import NotFoundView from '../../views/NotFoundView'; | ||
|
||
interface RequireGuestProps {} | ||
|
||
function RequireGuest(props: PropsWithChildren<RequireGuestProps>) { | ||
const { isGuest } = useUser(); | ||
|
||
if (isGuest) { | ||
return props.children; | ||
} | ||
|
||
return <NotFoundView />; | ||
} | ||
|
||
export default RequireGuest; |
29 changes: 0 additions & 29 deletions
29
frontend/src/components/FetchInterceptor/FetchInterceptor.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.