fix(web): reset global state after logout (#842)

* fix: global state bug fix.

* refactor: fix text being center.

* adapt mobile logout button for new logout function

---------

Co-authored-by: KaiserBh <kaiserbh@proton.me>
Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
KaiserBh 2023-04-17 02:39:45 +10:00 committed by GitHub
parent f3cfeed8cd
commit fe71dfc3af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 44 deletions

View file

@ -1,33 +0,0 @@
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>
);
};