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>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
middleware: ["login-required"]
|
||||
})
|
||||
const loading_btn = ref(false)
|
||||
const toast = useToast()
|
||||
|
||||
|
||||
const schema = z.object({
|
||||
@@ -30,11 +31,38 @@
|
||||
|
||||
async function submitChanges(event: FormSubmitEvent<Schema>) {
|
||||
loading_btn.value = true
|
||||
await $fetch("/settings/changepw", {
|
||||
method: "POST",
|
||||
body: pw_fields.value
|
||||
try {
|
||||
fetch("/settings/changepw", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(pw_fields.value)
|
||||
}).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'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
catch(err:any) {
|
||||
toast.add({
|
||||
title: 'Error',
|
||||
description: err?.data?.statusMessage || err.message || 'Something went wrong',
|
||||
color: 'error'
|
||||
})
|
||||
}
|
||||
loading_btn.value = false
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
9
server/py/.vscode/launch.json
vendored
Normal file
9
server/py/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
]
|
||||
}
|
||||
3
server/py/.vscode/settings.json
vendored
Normal file
3
server/py/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python-envs.pythonProjects": []
|
||||
}
|
||||
Reference in New Issue
Block a user