From 5ee9b01ee611fdc33ea3c4250366f8021a9d3c71 Mon Sep 17 00:00:00 2001 From: HenriT Date: Wed, 17 Feb 2021 11:11:12 +0200 Subject: [PATCH] Fix success messages. --- src/components/bank-accounts/BankAccountForm.vue | 8 ++++---- src/components/clients/ClientForm.vue | 12 ++++++------ src/components/invoices/InvoiceControls.vue | 4 ++-- src/services/bank-account.service.js | 3 ++- src/services/invoice.service.js | 3 ++- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/bank-accounts/BankAccountForm.vue b/src/components/bank-accounts/BankAccountForm.vue index 4fc1b5b..d7717c7 100644 --- a/src/components/bank-accounts/BankAccountForm.vue +++ b/src/components/bank-accounts/BankAccountForm.vue @@ -71,10 +71,10 @@ export default { this.errors.clear(); return this.$store.dispatch('bankAccounts/updateBankAccount', props) - .then((res) => { - NotificationService.success(res.message); + .then(() => { + NotificationService.success('Updated'); }) - .catch(err => this.errors.set(err.response.data.errors)); + .catch(err => this.errors.set(err.errors)); }, createBankAccount() { this.loading = true; @@ -89,7 +89,7 @@ export default { }); this.$emit('done'); }) - .catch(err => this.errors.set(err.response.data.errors)) + .catch(err => this.errors.set(err.errors)) .finally(() => { this.loading = false; }); diff --git a/src/components/clients/ClientForm.vue b/src/components/clients/ClientForm.vue index 52f45ca..1556c11 100644 --- a/src/components/clients/ClientForm.vue +++ b/src/components/clients/ClientForm.vue @@ -119,10 +119,10 @@ export default { this.errors.clear(); this.$store.dispatch('clients/updateClient', props) - .then((res) => { - NotificationService.success(res.message); + .then(() => { + NotificationService.success('Updated'); }) - .catch(err => this.errors.set(err.response.data.errors)); + .catch(err => this.errors.set(err.errors)); }, bankAccountChanged(val) { this.updateProp({ @@ -143,7 +143,7 @@ export default { }); this.$emit('done'); }) - .catch(err => this.errors.set(err.response.data.errors)) + .catch(err => this.errors.set(err.errors)) .finally(() => { this.loading = false; }); @@ -158,9 +158,9 @@ export default { }); if (confirmed) { this.$emit('done'); - const res = await this.$store.dispatch('clients/deleteClient', clientId); + await this.$store.dispatch('clients/deleteClient', clientId); try { - NotificationService.success(res.message); + NotificationService.success('Deleted'); } catch (err) { NotificationService.error(err.message); } diff --git a/src/components/invoices/InvoiceControls.vue b/src/components/invoices/InvoiceControls.vue index 161d9ae..85eec75 100644 --- a/src/components/invoices/InvoiceControls.vue +++ b/src/components/invoices/InvoiceControls.vue @@ -58,8 +58,8 @@ export default { contentClass: 'bg-base dp--24', }); if (confirmed) { - const res = await this.$store.dispatch('invoices/deleteInvoice', this.invoice); - NotificationService.success(res.message); + await this.$store.dispatch('invoices/deleteInvoice', this.invoice); + NotificationService.success('Deleted'); this.$router.push({ name: 'invoices', }); diff --git a/src/services/bank-account.service.js b/src/services/bank-account.service.js index a0dc1b7..defa5b8 100644 --- a/src/services/bank-account.service.js +++ b/src/services/bank-account.service.js @@ -30,7 +30,8 @@ class BankAccountService { } else { bankAccounts[index] = bankAccount; } - return storage.setItem('bank_accounts', bankAccounts); + await storage.setItem('bank_accounts', bankAccounts); + return bankAccount; } } diff --git a/src/services/invoice.service.js b/src/services/invoice.service.js index c0e4723..5311f75 100644 --- a/src/services/invoice.service.js +++ b/src/services/invoice.service.js @@ -124,7 +124,8 @@ class InvoiceService { } else { invoices[index] = invoice; } - return storage.setItem('invoices', invoices); + await storage.setItem('invoices', invoices); + return invoice; } }