fix payment/create and customer email validation

This commit is contained in:
yogesh_gohil
2019-11-20 12:39:11 +05:30
parent 220b62518f
commit 0442217dc2
4 changed files with 23 additions and 13 deletions

View File

@ -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:

View File

@ -34,7 +34,7 @@
</div>
</div>
<button class="list-add-button" @click="openCustomerModal">
<button type="button" class="list-add-button" @click="openCustomerModal">
<font-awesome-icon class="icon" icon="user-plus" />
<label>{{ $t('customers.add_new_customer') }}</label>
</button>

View File

@ -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) {

View File

@ -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)
}
}
}
},