From 1c61a4d202b9fa83cb50f8e6ecae7afd0e13b073 Mon Sep 17 00:00:00 2001 From: matiasc18 Date: Tue, 24 Mar 2026 16:39:53 -0400 Subject: [PATCH] Delete account in sidebar --- src/Home/AuthPage/EnterCode.js | 2 +- src/components/Sidebar.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Home/AuthPage/EnterCode.js b/src/Home/AuthPage/EnterCode.js index c3a9664..7179e3c 100644 --- a/src/Home/AuthPage/EnterCode.js +++ b/src/Home/AuthPage/EnterCode.js @@ -82,7 +82,7 @@ class EnterCode extends Shadow { console.log("submit") const res = await fetch(`${util.HOST}/auth/joincode`, { method: 'POST', - headers: { 'Content-Type': 'application/json', "Accept": "application/json" }, + headers: { 'Content-Type': 'application/json', "Accept": "application/json", "X-Client": "mobile" }, body: JSON.stringify({ code: this.$("input").value }) }); diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 7376a02..02e454e 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -21,6 +21,8 @@ class Sidebar extends Shadow { global.onLogout() $("home-").closeSidebar(); return + } else if (this.innerText === "Delete account") { + $("sidebar-").deleteAccount(); } } }) @@ -63,6 +65,7 @@ class Sidebar extends Shadow { }) this.SidebarItem("Logout") + this.SidebarItem("Delete account") }) .gap(1, em) .paddingTop(15, vh) @@ -82,6 +85,26 @@ class Sidebar extends Shadow { $("appwindowcontainer-").openProfile() $("home-").closeSidebar(); } + + async deleteAccount() { + try { + const res = await util.authFetch(`${util.HOST}/auth/delete`, { + method: "DELETE", + credentials: "include", + headers: { + "X-Client": "mobile", + "Content-Type": "application/json", + "Accept": "application/json" + }, + body: JSON.stringify({ memberId: global.profile.id }) + }); + + if (!res.ok) return; + global.onLogout() + } catch (err) { + console.error(err) + } + } } register(Sidebar) \ No newline at end of file