autobrr/web/src/screens/auth/logout.tsx
stacksmash76 bb2641f447
fix(web): correctly replace logout url (#316)
* chore(ErrorPage): clean up code, fix typo
fix(Logout): replace /logout URL after logging out to /

* chore: remove needless TS type export
2022-06-18 07:27:19 +02:00

33 lines
977 B
TypeScript

import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import toast from "react-hot-toast";
import { APIClient } from "../../api/APIClient";
import { AuthContext } from "../../utils/Context";
import Toast from "../../components/notifications/Toast";
export const Logout = () => {
const navigate = useNavigate();
useEffect(
() => {
APIClient.auth.logout()
.then(() => {
AuthContext.reset();
toast.custom((t) => (
<Toast type="success" body="You have been logged out. Goodbye!" t={t} />
));
// Dirty way to fix URL without triggering a re-render.
// Ideally, we'd move the logout component to a function.
setInterval(() => navigate("/", { replace: true }), 250);
});
},
[]
);
return (
<div className="min-h-screen flex justify-center items-center">
{/*<h1 className="font-bold text-7xl">Goodbye!</h1>*/}
</div>
);
};