2025-03-07 18:43:24 +01:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<h1>Account Settings</h1>
|
2025-03-07 23:53:57 +01:00
|
|
|
<p v-if="session?.account.type !== 'anonymous'">
|
|
|
|
Name: {{ session?.account.name }}
|
|
|
|
</p>
|
2025-03-07 18:43:24 +01:00
|
|
|
<p>Access: {{ session?.account.type }}</p>
|
2025-03-09 15:53:51 +01:00
|
|
|
<form @submit.prevent="changeSettings">
|
|
|
|
<label>
|
|
|
|
Timezone
|
|
|
|
<input type="text" v-model="timezone">
|
|
|
|
</label>
|
|
|
|
<button type="submit">
|
|
|
|
Save
|
|
|
|
</button>
|
|
|
|
</form>
|
2025-03-07 18:43:24 +01:00
|
|
|
<p>
|
2025-05-23 21:35:19 +02:00
|
|
|
<ClientOnly>
|
|
|
|
<PushNotification />
|
|
|
|
</ClientOnly>
|
2025-03-07 18:43:24 +01:00
|
|
|
</p>
|
2025-03-07 22:28:55 +01:00
|
|
|
<fieldset>
|
|
|
|
<legend>Danger Zone</legend>
|
|
|
|
Delete my account and all data associated with it
|
|
|
|
<button @click="deleteAccount">
|
|
|
|
Delete
|
|
|
|
</button>
|
|
|
|
</fieldset>
|
2025-03-07 18:43:24 +01:00
|
|
|
</main>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
definePageMeta({
|
|
|
|
middleware: ["authenticated"],
|
|
|
|
});
|
|
|
|
|
2025-05-23 21:33:48 +02:00
|
|
|
const { data: session, refresh: sessionRefresh } = await useAccountSession();
|
2025-03-07 22:28:55 +01:00
|
|
|
|
2025-03-09 15:53:51 +01:00
|
|
|
const timezone = ref(session.value?.account.timezone ?? "");
|
|
|
|
|
|
|
|
async function changeSettings() {
|
|
|
|
try {
|
|
|
|
await $fetch("/api/account", {
|
|
|
|
method: "patch",
|
|
|
|
body: {
|
|
|
|
timezone: timezone.value,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
await sessionRefresh();
|
|
|
|
} catch (err: any) {
|
|
|
|
alert(err.data.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-07 22:28:55 +01:00
|
|
|
async function deleteAccount() {
|
|
|
|
try {
|
|
|
|
await $fetch.raw("/api/account", {
|
|
|
|
method: "DELETE",
|
|
|
|
});
|
|
|
|
await sessionRefresh();
|
|
|
|
await navigateTo("/");
|
2025-03-07 18:43:24 +01:00
|
|
|
|
2025-03-07 22:28:55 +01:00
|
|
|
} catch (err: any) {
|
|
|
|
alert(`Delete account failed: ${err.statusCode} ${err.statusMessage}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|