From 665fc768563a99e1672c1eb41ca0bdad82d4b87d Mon Sep 17 00:00:00 2001 From: yogesh_gohil Date: Wed, 20 Nov 2019 12:45:24 +0530 Subject: [PATCH] fix customer modal email validation --- .../components/base/modal/CustomerModal.vue | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/resources/assets/js/components/base/modal/CustomerModal.vue b/resources/assets/js/components/base/modal/CustomerModal.vue index 101564a1..b0f3a174 100644 --- a/resources/assets/js/components/base/modal/CustomerModal.vue +++ b/resources/assets/js/components/base/modal/CustomerModal.vue @@ -629,21 +629,28 @@ export default { } else { this.formData.currency_id = this.defaultCurrency.id } - let response = await this.addCustomer(this.formData) - if (response.data) { - window.toastr['success'](this.$tc('customers.created_message')) - this.isLoading = false - if (this.$route.name === 'invoices.create') { - this.setInvoiceCustomer(response.data.customer.id) + try { + let response = await this.addCustomer(this.formData) + if (response.data) { + window.toastr['success'](this.$tc('customers.created_message')) + this.isLoading = false + if (this.$route.name === 'invoices.create') { + this.setInvoiceCustomer(response.data.customer.id) + } + if (this.$route.name === 'estimates.create') { + this.setEstimateCustomer(response.data.customer.id) + } + this.resetData() + this.closeModal() + return true } - if (this.$route.name === 'estimates.create') { - this.setEstimateCustomer(response.data.customer.id) + // window.toastr['error'](response.data.error) + } catch (err) { + if (err.response.data.errors.email) { + this.isLoading = false + window.toastr['error'](this.$t('validation.email_already_taken')) } - this.resetData() - this.closeModal() - return true } - window.toastr['error'](response.data.error) }, async fetchCountry () { let res = await window.axios.get('/api/countries')