Add per account overridable timezone setting

To make it possible to render the timetable in the user's local time we
need to know the timezone to render it in on the server.  Otherwise
there will be hydration errors and paint flashing as the client renders
a different timezone.

Add a server global default timezone that can be overriden on a
per-account bases to prepare for timezone handling the timetable.
This commit is contained in:
Hornwitser 2025-03-09 15:53:51 +01:00
parent 264c97b586
commit c4a6f6b3f9
6 changed files with 83 additions and 7 deletions

View file

@ -5,6 +5,15 @@
Name: {{ session?.account.name }}
</p>
<p>Access: {{ session?.account.type }}</p>
<form @submit.prevent="changeSettings">
<label>
Timezone
<input type="text" v-model="timezone">
</label>
<button type="submit">
Save
</button>
</form>
<p>
<PushNotification />
</p>
@ -26,6 +35,22 @@ definePageMeta({
const { data: session } = useAccountSession();
const { refresh: sessionRefresh } = useAccountSession();
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);
}
}
async function deleteAccount() {
try {
await $fetch.raw("/api/account", {