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>
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
<form
|
|
|
|
|
class="mt-3"
|
|
|
|
|
@submit.prevent="update"
|
|
|
|
|
@keydown="form.onKeydown($event)"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
<!-- Name -->
|
2024-04-15 19:39:03 +02:00
|
|
|
<text-input
|
|
|
|
|
name="name"
|
|
|
|
|
:form="form"
|
|
|
|
|
label="Name"
|
|
|
|
|
:required="true"
|
|
|
|
|
/>
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
<!-- Email -->
|
2024-04-15 19:39:03 +02:00
|
|
|
<text-input
|
|
|
|
|
name="email"
|
|
|
|
|
:form="form"
|
|
|
|
|
label="Email"
|
|
|
|
|
:required="true"
|
|
|
|
|
/>
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
<!-- Submit Button -->
|
2024-04-15 19:39:03 +02:00
|
|
|
<v-button
|
|
|
|
|
:loading="form.busy"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
Save changes
|
|
|
|
|
</v-button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-01-02 13:09:41 +01:00
|
|
|
<script setup>
|
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
|
const user = computed(() => authStore.user)
|
2024-01-04 18:38:50 +01:00
|
|
|
|
|
|
|
|
useOpnSeoMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Profile",
|
2024-01-04 18:38:50 +01:00
|
|
|
})
|
2024-01-05 10:47:36 +01:00
|
|
|
definePageMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
middleware: "auth",
|
2024-01-05 10:47:36 +01:00
|
|
|
})
|
2024-01-04 18:38:50 +01:00
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
const form = useForm({
|
|
|
|
|
name: "",
|
|
|
|
|
email: "",
|
2024-01-02 13:09:41 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const update = () => {
|
2024-04-15 19:39:03 +02:00
|
|
|
form.patch("/settings/profile").then((response) => {
|
2024-01-02 13:09:41 +01:00
|
|
|
authStore.updateUser(response)
|
2024-04-15 19:39:03 +02:00
|
|
|
useAlert().success("Your info has been updated!")
|
2024-01-02 13:09:41 +01:00
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
}
|
2024-01-02 13:09:41 +01:00
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
|
// Fill the form with user data.
|
2024-04-15 19:39:03 +02:00
|
|
|
form.keys().forEach((key) => {
|
2024-01-02 13:09:41 +01:00
|
|
|
form[key] = user.value[key]
|
|
|
|
|
})
|
|
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
</script>
|