-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created user public and private routes
- Loading branch information
1 parent
f7421e6
commit 11015f5
Showing
4 changed files
with
82 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
export const MyOrder = () => { | ||
return ( | ||
<div>MyOrder</div> | ||
) | ||
} |
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 React from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { Navigate } from "react-router-dom"; | ||
import { | ||
selectUserAccessToken, | ||
selectUserInfo, | ||
} from "../../features/auth/userAuthSelectors"; | ||
|
||
export const UserPrivateRoute = ({ children }) => { | ||
const user = useSelector(selectUserInfo); | ||
const accessToken = useSelector(selectUserAccessToken); | ||
|
||
return user !== undefined && accessToken !== undefined ? ( | ||
children | ||
) : ( | ||
<Navigate to="/login" /> | ||
); | ||
}; |
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 React from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { Navigate } from "react-router-dom"; | ||
import { | ||
selectUserAccessToken, | ||
selectUserInfo, | ||
} from "../../features/auth/userAuthSelectors"; | ||
|
||
export const UserPublicRoute = ({ children }) => { | ||
const user = useSelector(selectUserInfo); | ||
const accessToken = useSelector(selectUserAccessToken); | ||
|
||
return user !== undefined && accessToken !== undefined ? ( | ||
<Navigate to="/" /> | ||
) : ( | ||
children | ||
); | ||
}; |