From ae55c473192561cfe95b858747be9f4f595d2f7b Mon Sep 17 00:00:00 2001 From: keannu125 Date: Fri, 24 Feb 2023 18:59:57 +0800 Subject: [PATCH] Redirect back to dashboard when logging out --- src/Components/Logout/Logout.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Components/Logout/Logout.tsx b/src/Components/Logout/Logout.tsx index 1fcfef1..4b99181 100644 --- a/src/Components/Logout/Logout.tsx +++ b/src/Components/Logout/Logout.tsx @@ -3,6 +3,7 @@ import { useSelector, useDispatch } from "react-redux"; import { toggle } from "../../Features/Login/LoginSlice"; import { Button } from "@mui/material"; import styles from "../../styles"; +import { useNavigate } from "react-router-dom"; export interface state { logged_in: { @@ -16,16 +17,17 @@ export interface props { export default function Logout(props: props) { const logged_in = useSelector((state: state) => state.logged_in.value); const dispatch = useDispatch(); + const navigate = useNavigate(); - async function login() { + async function logout() { await dispatch(toggle()); - await console.log("test " + logged_in); + navigate("/"); } return (