fix customer modal email validation

This commit is contained in:
yogesh_gohil
2019-11-20 12:45:24 +05:30
parent 0442217dc2
commit 665fc76856

View File

@ -629,21 +629,28 @@ export default {
} else { } else {
this.formData.currency_id = this.defaultCurrency.id this.formData.currency_id = this.defaultCurrency.id
} }
let response = await this.addCustomer(this.formData) try {
if (response.data) { let response = await this.addCustomer(this.formData)
window.toastr['success'](this.$tc('customers.created_message')) if (response.data) {
this.isLoading = false window.toastr['success'](this.$tc('customers.created_message'))
if (this.$route.name === 'invoices.create') { this.isLoading = false
this.setInvoiceCustomer(response.data.customer.id) 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') { // window.toastr['error'](response.data.error)
this.setEstimateCustomer(response.data.customer.id) } 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 () { async fetchCountry () {
let res = await window.axios.get('/api/countries') let res = await window.axios.get('/api/countries')