diff --git a/web/src/domain/routes.tsx b/web/src/domain/routes.tsx index 5771f87..370b632 100644 --- a/web/src/domain/routes.tsx +++ b/web/src/domain/routes.tsx @@ -1,7 +1,6 @@ import { BrowserRouter, Route, Routes } from "react-router-dom"; import { Login } from "../screens/auth/login"; -import { Logout } from "../screens/auth/logout"; import { Onboarding } from "../screens/auth/onboarding"; import Base from "../screens/Base"; import { Dashboard } from "../screens/dashboard"; @@ -28,7 +27,6 @@ export const LocalRouter = ({ isLoggedIn }: { isLoggedIn: boolean }) => ( {isLoggedIn ? ( - } /> }> } /> } /> diff --git a/web/src/screens/Base.tsx b/web/src/screens/Base.tsx index 5b352d8..1f9631d 100644 --- a/web/src/screens/Base.tsx +++ b/web/src/screens/Base.tsx @@ -9,6 +9,8 @@ import { AuthContext } from "../utils/Context"; import logo from "../logo.png"; import { useQuery } from "react-query"; import { APIClient } from "../api/APIClient"; +import toast from "react-hot-toast"; +import Toast from "@/components/notifications/Toast"; interface NavItem { name: string; @@ -40,6 +42,16 @@ export default function Base() { } ); + const LogOutUser = () => { + APIClient.auth.logout() + .then(() => { + AuthContext.reset(); + toast.custom((t) => ( + + )); + }); + }; + return (
{({ active }) => ( - - Logout - + Log out + )} @@ -229,12 +241,12 @@ export default function Base() { {item.name} ))} - Logout - +
diff --git a/web/src/screens/auth/logout.tsx b/web/src/screens/auth/logout.tsx deleted file mode 100644 index 8ba76aa..0000000 --- a/web/src/screens/auth/logout.tsx +++ /dev/null @@ -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) => ( - - )); - - // 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 ( -
- {/*

Goodbye!

*/} -
- ); -};