added toaster messages

This commit is contained in:
2026-01-20 17:41:06 +00:00
parent 2c5c34eeac
commit a9a6de8738
4 changed files with 63 additions and 6 deletions

View File

@@ -6,6 +6,7 @@
layout: "settings",
middleware: ["login-required"]
})
const toast = useToast()
const { data: user_data, refresh: userRefresh } = useFetch("/me");
const loading_btn = ref(false)
@@ -20,14 +21,30 @@
async function submitChanges(event: FormSubmitEvent<Schema>) {
loading_btn.value = true
await $fetch("/settings/edit_user", {
await fetch("/settings/edit_user", {
method: "POST",
body: {
body: JSON.stringify({
first_name: user_data.value.first_name,
last_name: user_data.value.last_name,
email: user_data.value.email
})
}).then(async (response) => {
const body = await response.json()
if (response.ok) {
toast.add({
title: "Done!",
description: "It's changed!",
color: "success"
})
}
})
else {
toast.add({
title: 'Error',
description : body.statusMessage || body.message || 'Something went wrong',
color: 'error'
})
}
})
loading_btn.value = false
}
</script>