mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
fix payment/create and customer email validation
This commit is contained in:
@ -36,6 +36,7 @@ class CustomerRequest extends FormRequest
|
|||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'addresses.*.address_street_1' => 'max:255',
|
'addresses.*.address_street_1' => 'max:255',
|
||||||
'addresses.*.address_street_2' => 'max:255',
|
'addresses.*.address_street_2' => 'max:255',
|
||||||
|
'email' => 'email|nullable|unique:users,email',
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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" />
|
<font-awesome-icon class="icon" icon="user-plus" />
|
||||||
<label>{{ $t('customers.add_new_customer') }}</label>
|
<label>{{ $t('customers.add_new_customer') }}</label>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -608,16 +608,20 @@ export default {
|
|||||||
this.formData.currency_id = this.currency.id
|
this.formData.currency_id = this.currency.id
|
||||||
}
|
}
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
try {
|
||||||
let response = await this.updateCustomer(this.formData)
|
let response = await this.updateCustomer(this.formData)
|
||||||
|
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
window.toastr['success'](this.$t('customers.updated_message'))
|
window.toastr['success'](this.$t('customers.updated_message'))
|
||||||
this.$router.push('/admin/customers')
|
this.$router.push('/admin/customers')
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
window.toastr['error'](response.data.error)
|
if (err.response.data.errors.email) {
|
||||||
|
this.isLoading = false
|
||||||
|
window.toastr['error'](this.$t('validation.email_already_taken'))
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
if (this.currency) {
|
if (this.currency) {
|
||||||
|
|||||||
@ -246,16 +246,21 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
customer (newValue) {
|
customer (newValue) {
|
||||||
this.formData.user_id = newValue.id
|
this.formData.user_id = newValue.id
|
||||||
|
this.invoice = null
|
||||||
|
this.formData.amount = 0
|
||||||
|
this.invoiceList = []
|
||||||
if (!this.isEdit) {
|
if (!this.isEdit) {
|
||||||
this.fetchCustomerInvoices(newValue.id)
|
this.fetchCustomerInvoices(newValue.id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
invoice (newValue) {
|
invoice (newValue) {
|
||||||
|
if (newValue) {
|
||||||
this.formData.invoice_id = newValue.id
|
this.formData.invoice_id = newValue.id
|
||||||
if (!this.isEdit) {
|
if (!this.isEdit) {
|
||||||
this.setPaymentAmountByInvoiceData(newValue.id)
|
this.setPaymentAmountByInvoiceData(newValue.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async mounted () {
|
async mounted () {
|
||||||
// if (!this.$route.params.id) {
|
// if (!this.$route.params.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user