Skip to content

Commit

Permalink
Merge Refresh with useHistory #275
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt authored Aug 9, 2022
2 parents 754b628 + 925273f commit 55eec09
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/ClientApp/src/components/Layout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react";
import { useHistory } from "react-router-dom";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import {
Expand Down Expand Up @@ -36,6 +37,15 @@ export function Layout(props) {
setOpen(!open);
};

async function handleLogout() {
const response = await fetch("/login/sls/auth?cmd=logout");
if (response.ok) {
history.push("/");
}
}

const history = useHistory();

return (
<ThemeProvider theme={mdTheme}>
<Box sx={{ display: "flex" }}>
Expand All @@ -62,16 +72,9 @@ export function Layout(props) {
Grundlagedaten EWS
</Typography>
<Tooltip title="Abmelden">
<a href={window.location.origin.toString() + "/login/sls/auth?cmd=logout"}>
<IconButton
onClick={() => {
setTimeout(window.location.reload, 1000);
}}
sx={{ color: "white" }}
>
<LogoutIcon />
</IconButton>
</a>
<IconButton onClick={handleLogout} sx={{ color: "white" }}>
<LogoutIcon />
</IconButton>
</Tooltip>
</Toolbar>
</AppBar>
Expand Down

0 comments on commit 55eec09

Please sign in to comment.