Use a pinia store to manage account state
All checks were successful
/ build (push) Successful in 3m29s
/ deploy (push) Successful in 47s

Refactor the existing scattered code dealing with the account state into
a pinia store.
This commit is contained in:
Hornwitser 2025-05-24 20:01:23 +02:00
parent fae8b4e2e4
commit e722876aae
12 changed files with 126 additions and 98 deletions

View file

@ -1,14 +1,14 @@
<template>
<main>
<h1>Account Settings</h1>
<p v-if="sessionStore.account?.type !== 'anonymous'">
Name: {{ sessionStore.account?.name }}
<p v-if="accountStore.type !== 'anonymous'">
Name: {{ accountStore.name }}
</p>
<p>Access: {{ sessionStore.account?.type }}</p>
<p>Access: {{ accountStore.type }}</p>
<form @submit.prevent="changeSettings">
<label>
Timezone
<input type="text" v-model="timezone">
<input type="text" v-model="timezone" :placeholder="accountStore.defaultTimezone">
</label>
<button type="submit">
Save
@ -35,8 +35,9 @@ definePageMeta({
});
const sessionStore = useSessionStore();
const accountStore = useAccountStore();
const timezone = ref(sessionStore.account?.timezone ?? "");
const timezone = ref(accountStore.timezone ?? "");
async function changeSettings() {
try {