added toaster messages
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user