mirror of
https://github.com/idanoo/autobrr
synced 2025-07-26 10:19:13 +00:00
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:
parent
f3cfeed8cd
commit
fe71dfc3af
3 changed files with 21 additions and 44 deletions
|
@ -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>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue