diff --git a/src/app/logout/page.tsx b/src/app/logout/page.tsx index 7809ae8..75e9f60 100644 --- a/src/app/logout/page.tsx +++ b/src/app/logout/page.tsx @@ -6,11 +6,28 @@ import { toast } from "react-toastify"; export default function UserPage() { useEffect(() => { - document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + async function logout() { + const response = await fetch( + process.env.NEXT_PUBLIC_MODE === "PROD" + ? "https://d2jam.com/api/v1/logout" + : "http://localhost:3005/api/v1/logout", + { method: "POST", credentials: "include" } + ); - toast.success("Successfully logged out"); + if (response.ok) { + document.cookie = + "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + document.cookie = + "user=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; - redirect("/"); + toast.success("Successfully logged out"); + redirect("/"); + } else { + toast.error("Error while trying to log out"); + } + } + + logout(); }); return ( diff --git a/src/components/navbar/PCNavbarUser.tsx b/src/components/navbar/PCNavbarUser.tsx index 68e9797..1931a9b 100644 --- a/src/components/navbar/PCNavbarUser.tsx +++ b/src/components/navbar/PCNavbarUser.tsx @@ -28,7 +28,7 @@ export default function PCNavbarUser({ user }: NavbarUserProps) { <DropdownMenu> <DropdownItem key="profile" - className="text-black" + className="text-[#333] dark:text-white" href={`/u/${user.slug}`} > Profile @@ -36,7 +36,7 @@ export default function PCNavbarUser({ user }: NavbarUserProps) { <DropdownItem showDivider key="settings" - className="text-black" + className="text-[#333] dark:text-white" href="/settings" > Settings