opnform-host-nginx/client/pages/settings/profile.vue

70 lines
1.3 KiB
Vue
Raw Normal View History

2023-12-09 15:47:03 +01:00
<template>
<div>
<h3 class="font-semibold text-2xl text-gray-900">
Profile details
</h3>
<small class="text-gray-600">Update your username and manage your account details.</small>
<form
class="mt-3"
@submit.prevent="update"
@keydown="form.onKeydown($event)"
>
2023-12-09 15:47:03 +01:00
<!-- Name -->
<text-input
name="name"
:form="form"
label="Name"
:required="true"
/>
2023-12-09 15:47:03 +01:00
<!-- Email -->
<text-input
name="email"
:form="form"
label="Email"
:required="true"
/>
2023-12-09 15:47:03 +01:00
<!-- Submit Button -->
<v-button
:loading="form.busy"
class="mt-4"
>
2023-12-09 15:47:03 +01:00
Save changes
</v-button>
</form>
</div>
</template>
<script setup>
const authStore = useAuthStore()
const user = computed(() => authStore.user)
useOpnSeoMeta({
title: "Profile",
})
definePageMeta({
middleware: "auth",
})
const form = useForm({
name: "",
email: "",
})
const update = () => {
form.patch("/settings/profile").then((response) => {
authStore.updateUser(response)
useAlert().success("Your info has been updated!")
})
2023-12-09 15:47:03 +01:00
}
onBeforeMount(() => {
// Fill the form with user data.
form.keys().forEach((key) => {
form[key] = user.value[key]
})
})
2023-12-09 15:47:03 +01:00
</script>