diff --git a/src/App.vue b/src/App.vue index 4f1394559..b928491a3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -44,6 +44,11 @@ function responseError(error) { let message = error.message; let logOut = false; + const response = error.response; + if (response && response.data.error) { + message = response.data.error.message; + } + switch (error.response?.status) { case 401: message = 'login.loginError'; diff --git a/src/components/common/SendEmailDialog.vue b/src/components/common/SendEmailDialog.vue index 0db0af056..0ede6c441 100644 --- a/src/components/common/SendEmailDialog.vue +++ b/src/components/common/SendEmailDialog.vue @@ -3,12 +3,13 @@ import { ref } from 'vue'; import { useDialogPluginComponent } from 'quasar'; import { useI18n } from 'vue-i18n'; -const $props = defineProps({ - address: { - type: String, - default: '', +const props = defineProps({ + data: { + type: Object, + requied: true, + default: null, }, - send: { + promise: { type: Function, required: true, }, @@ -19,24 +20,30 @@ defineEmits(['confirm', ...useDialogPluginComponent.emits]); const { dialogRef, onDialogOK } = useDialogPluginComponent(); const { t } = useI18n(); -const address = ref($props.address); +const address = ref(props.data.address); const isLoading = ref(false); async function confirm() { - isLoading.value = true; - await $props.send(address.value); - isLoading.value = false; + const response = { address }; - onDialogOK(); + if (props.promise) { + isLoading.value = true; + try { + Object.assign(response, props.data); + await props.promise(response); + } finally { + isLoading.value = false; + } + } + + onDialogOK(response); }