Skip to content

Commit

Permalink
Replace logout placeholder with real function
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jul 30, 2021
1 parent c2d2b07 commit dfff8ca
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/AppView/AppView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import ItemTable from "../ItemTable/";
import ItemViewAppBar from "../ItemViewAppBar/";
import ItemView from "../ItemView/";
import QueueSelector from "../QueueSelector/";
import { useToken } from "../AuthProvider/";
import { useToken, useLoginSetter } from "../AuthProvider/";
import { useCookies } from "react-cookie";

export default function AppView({ setDarkMode }) {
// Create stateful variables.
Expand All @@ -27,6 +28,8 @@ export default function AppView({ setDarkMode }) {
const [errorResponse, setErrorResponse] = useState({ code: "", description: "", message: "" })

const access_token = useToken();
const setLogin = useLoginSetter();
const [cookies, removeCookie] = useCookies(["csrf_refresh_token"]);

// Get Queues from API.
useEffect(_ => {
Expand Down Expand Up @@ -148,6 +151,11 @@ export default function AppView({ setDarkMode }) {
);
}

const handleLogout = () => {
setLogin(false);
removeCookie(["csrf_refresh_token"])
}

const darkMode = theme.palette.type === "dark"
const itemtableappbarActions = [
<ItemTableAppBarAction
Expand All @@ -157,7 +165,7 @@ export default function AppView({ setDarkMode }) {
/>,
<ItemTableAppBarAction
title="Logout"
onClick={_ => alert("Hazzah!")}
onClick={handleLogout}
icon={<LogoutIcon />}
/>
]
Expand Down

0 comments on commit dfff8ca

Please sign in to comment.