mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-17 06:39:25 +08:00
Merge pull request #3 from lemeow125/feature/polishlogin
Redirect back to dashboard when logging out
This commit is contained in:
commit
fe463418f9
1 changed files with 5 additions and 3 deletions
|
@ -3,6 +3,7 @@ import { useSelector, useDispatch } from "react-redux";
|
||||||
import { toggle } from "../../Features/Login/LoginSlice";
|
import { toggle } from "../../Features/Login/LoginSlice";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export interface state {
|
export interface state {
|
||||||
logged_in: {
|
logged_in: {
|
||||||
|
@ -16,16 +17,17 @@ export interface props {
|
||||||
export default function Logout(props: props) {
|
export default function Logout(props: props) {
|
||||||
const logged_in = useSelector((state: state) => state.logged_in.value);
|
const logged_in = useSelector((state: state) => state.logged_in.value);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
async function login() {
|
async function logout() {
|
||||||
await dispatch(toggle());
|
await dispatch(toggle());
|
||||||
await console.log("test " + logged_in);
|
navigate("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ paddingTop: "40vh" }}>
|
<div style={{ paddingTop: "40vh" }}>
|
||||||
<Button
|
<Button
|
||||||
onClick={login}
|
onClick={logout}
|
||||||
value="Log out"
|
value="Log out"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
style={styles.logout_button}
|
style={styles.logout_button}
|
||||||
|
|
Loading…
Reference in a new issue