From 0fe6c20c6927be28fc974eb81008c292f728caf4 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:20 -0400 Subject: [PATCH] Implement logout function on nav --- components/Navigation.tsx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/components/Navigation.tsx b/components/Navigation.tsx index cc7d4bb..a3c047c 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -17,6 +17,14 @@ import { useDisclosure, } from "@chakra-ui/react"; +async function destroySession() { + await fetch("/api/auth/session", { + method: "DELETE", + }).catch(() => {}); + + location.assign("/"); +} + function getAvatarUrl(userData: { [k: string]: any }): string { const BASE = "https://cdn.discordapp.com/"; @@ -37,6 +45,7 @@ export default function (props: { permissions?: number; username?: string; }) { + let data = { ...props }; const isDesktop = useBreakpointValue({ base: false, lg: true }); const { isOpen, onClose, onOpen } = useDisclosure(); @@ -106,18 +115,19 @@ export default function (props: { - {props.hide ? null : props.id ? ( + {data.hide ? null : data.id ? ( - {props.id ? `${props.username}#${props.discriminator}` : ""} + {data.id ? `${data.username}#${data.discriminator}` : ""}