From 9fd9fb6744fe3ae0a8b4eaedd5639887de356ddd Mon Sep 17 00:00:00 2001 From: Radical Date: Mon, 23 Jun 2025 20:46:05 +0200 Subject: [PATCH] feat: code polishing co-authored-by: JustTemmie co-authored-by: SauceyRed --- components/Button.vue | 8 ++--- components/Settings/UserSettings/Account.vue | 36 ++++++++++---------- pages/settings.vue | 6 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/components/Button.vue b/components/Button.vue index 1374344..db8bb8e 100644 --- a/components/Button.vue +++ b/components/Button.vue @@ -21,11 +21,11 @@ const props = defineProps<{ background-color: #b35719; color: #ffffff; - padding: 8px 18px; - font-size: 18px; + padding: 0.7dvh 1.2dvw; + font-size: 1.1em; transition: background-color 0.2s; - border-radius: 12px; + border-radius: 0.7rem; text-decoration: none; display: inline-block; } @@ -38,7 +38,7 @@ const props = defineProps<{ background-color: grey; } -#button:hover { +.button:hover { background-color: #934410; } \ No newline at end of file diff --git a/components/Settings/UserSettings/Account.vue b/components/Settings/UserSettings/Account.vue index 5e883f5..0fe5013 100644 --- a/components/Settings/UserSettings/Account.vue +++ b/components/Settings/UserSettings/Account.vue @@ -2,8 +2,8 @@

My Account

-
-
+
+

AVATAR

@@ -21,14 +21,14 @@
- +
-

Password (and eventually authenticator)

+

Password (and eventually authenticator)

- +

Account Deletion

- +
@@ -39,20 +39,19 @@ import type { UserResponse } from '~/types/interfaces'; const { fetchUser } = useAuth(); -const user_me = await fetchUser() -if (user_me === undefined) { +const user: UserResponse | undefined = await fetchUser() +if (!user) { alert("could not fetch user info, aborting :(") } -let userReference = Object.assign({}, user_me) -const user: UserResponse = user_me! - -let newPfpFile: any = null +let newPfpFile: File; const saveChanges = async () => { + if (!user) return; + const formData = new FormData() - if (newPfpFile !== null) { + if (newPfpFile) { formData.append("avatar", newPfpFile) } @@ -70,7 +69,6 @@ const saveChanges = async () => { body: formData }) - userReference = Object.assign({}, await fetchUser()) alert('success!!') } catch (error: any) { if (error?.response?.status !== 200) { @@ -86,7 +84,9 @@ const removeAvatar = async () => { } const changeAvatar = async () => { - let input = document.createElement('input'); + if (!user) return; + + const input = document.createElement('input'); input.type = 'file'; input.accept = 'image/*'; @@ -98,7 +98,7 @@ const changeAvatar = async () => { newPfpFile = file const reader = new FileReader(); - reader.addEventListener("onload", (e: Event) => { + reader.addEventListener("onload", () => { if (reader.result && typeof reader.result === 'string') { user.avatar = reader.result; } @@ -121,7 +121,7 @@ const deleteAccount = async () => {