diff --git a/app/Http/Requests/CustomerRequest.php b/app/Http/Requests/CustomerRequest.php index d93e5de1..062f86b2 100644 --- a/app/Http/Requests/CustomerRequest.php +++ b/app/Http/Requests/CustomerRequest.php @@ -36,6 +36,7 @@ class CustomerRequest extends FormRequest 'name' => 'required', 'addresses.*.address_street_1' => 'max:255', 'addresses.*.address_street_2' => 'max:255', + 'email' => 'email|nullable|unique:users,email', ]; break; default: diff --git a/resources/assets/js/components/base/popup/CustomerSelectPopup.vue b/resources/assets/js/components/base/popup/CustomerSelectPopup.vue index d0f9994b..6d9ea0e4 100644 --- a/resources/assets/js/components/base/popup/CustomerSelectPopup.vue +++ b/resources/assets/js/components/base/popup/CustomerSelectPopup.vue @@ -34,7 +34,7 @@ - diff --git a/resources/assets/js/views/customers/Create.vue b/resources/assets/js/views/customers/Create.vue index 8b831584..69a45934 100644 --- a/resources/assets/js/views/customers/Create.vue +++ b/resources/assets/js/views/customers/Create.vue @@ -608,16 +608,20 @@ export default { this.formData.currency_id = this.currency.id } this.isLoading = true - let response = await this.updateCustomer(this.formData) - - if (response.data) { - window.toastr['success'](this.$t('customers.updated_message')) - this.$router.push('/admin/customers') - this.isLoading = false - return true + try { + let response = await this.updateCustomer(this.formData) + if (response.data) { + window.toastr['success'](this.$t('customers.updated_message')) + this.$router.push('/admin/customers') + this.isLoading = false + return true + } + } catch (err) { + if (err.response.data.errors.email) { + this.isLoading = false + window.toastr['error'](this.$t('validation.email_already_taken')) + } } - - window.toastr['error'](response.data.error) } else { this.isLoading = true if (this.currency) { diff --git a/resources/assets/js/views/payments/Create.vue b/resources/assets/js/views/payments/Create.vue index 1a0bea01..d31c5ab0 100644 --- a/resources/assets/js/views/payments/Create.vue +++ b/resources/assets/js/views/payments/Create.vue @@ -246,14 +246,19 @@ export default { watch: { customer (newValue) { this.formData.user_id = newValue.id + this.invoice = null + this.formData.amount = 0 + this.invoiceList = [] if (!this.isEdit) { this.fetchCustomerInvoices(newValue.id) } }, invoice (newValue) { - this.formData.invoice_id = newValue.id - if (!this.isEdit) { - this.setPaymentAmountByInvoiceData(newValue.id) + if (newValue) { + this.formData.invoice_id = newValue.id + if (!this.isEdit) { + this.setPaymentAmountByInvoiceData(newValue.id) + } } } },