-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navbar fully functional andadded logout component (that is also fully…
… functional). Totally responsive. Finishing night be completing user settings page now that it's easily accessible and able to be tested thanks to the previously stated milestone hit.
- Loading branch information
1 parent
bee52d4
commit 851d9ef
Showing
4 changed files
with
299 additions
and
260 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,40 @@ | ||
// when this component mounts, it will instanstly run clearToken: ABCtoken["clearToken"] from App.tsx and return the user to "/" | ||
import React from "react"; | ||
import { ABCtoken } from "../App"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
|
||
interface LogoutProps { | ||
clearToken: ABCtoken["clearToken"]; | ||
} | ||
|
||
//TODO could style this into a cool looking page if I have time to. | ||
|
||
const Logout = (props: LogoutProps) => { | ||
// On page loads, it tells the user "You are being logged out (countdown timer)." </br> "You will be redirected to the home page in 5 seconds." | ||
// When the countdown timer reaches 0, it will run the clearToken function from App.tsx and return the user to "/". | ||
const navigate = useNavigate(); | ||
const [countdown, setCountdown] = React.useState<number>(3); | ||
const [countdownInterval, setCountdownInterval] = React.useState<number>(0); | ||
|
||
React.useEffect(() => { | ||
if (countdown > 0) { | ||
setCountdownInterval(window.setInterval(() => { | ||
setCountdown(countdown - 1); | ||
}, 1000)); | ||
} else { | ||
props.clearToken(); | ||
navigate("/"); | ||
} | ||
}, [countdown, navigate, props]); | ||
|
||
return ( | ||
<div className="logout-container"> | ||
<h1>You are being logged out.</h1> | ||
|
||
<h2>Redirecting to the home page in {countdown} seconds.</h2> | ||
</div> | ||
); | ||
} | ||
|
||
export default Logout; |
Oops, something went wrong.