mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
Merge branch 'customer' into 'master'
Fix customer email already exist validation when edit customer See merge request mohit.panjvani/crater-web!71
This commit is contained in:
@ -160,6 +160,7 @@ class CustomersController extends Controller
|
|||||||
if ($verifyEmail) {
|
if ($verifyEmail) {
|
||||||
if ($verifyEmail->id !== $customer->id) {
|
if ($verifyEmail->id !== $customer->id) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
'error' => 'Email already in use'
|
'error' => 'Email already in use'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ 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,'.$this->id
|
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -586,11 +586,16 @@ export default {
|
|||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
try {
|
try {
|
||||||
let response = await this.updateCustomer(this.formData)
|
let response = await this.updateCustomer(this.formData)
|
||||||
if (response.data) {
|
if (response.data.success) {
|
||||||
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
|
||||||
|
} else {
|
||||||
|
this.isLoading = false
|
||||||
|
if (response.data.error) {
|
||||||
|
window.toastr['error'](this.$t('validation.email_already_taken'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response.data.errors.email) {
|
if (err.response.data.errors.email) {
|
||||||
|
|||||||
@ -83,7 +83,7 @@
|
|||||||
:allow-empty="false"
|
:allow-empty="false"
|
||||||
:disabled="isEdit"
|
:disabled="isEdit"
|
||||||
:placeholder="$t('invoices.select_invoice')"
|
:placeholder="$t('invoices.select_invoice')"
|
||||||
label="invoice_number"
|
:custom-label="invoiceWithAmount"
|
||||||
track-by="invoice_number"
|
track-by="invoice_number"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -283,6 +283,9 @@ export default {
|
|||||||
'updatePayment',
|
'updatePayment',
|
||||||
'fetchPayment'
|
'fetchPayment'
|
||||||
]),
|
]),
|
||||||
|
invoiceWithAmount ({ invoice_number, due_amount }) {
|
||||||
|
return `${invoice_number} (${this.$utils.formatGraphMoney(due_amount, this.customer.currency)})`
|
||||||
|
},
|
||||||
async loadData () {
|
async loadData () {
|
||||||
if (this.isEdit) {
|
if (this.isEdit) {
|
||||||
let response = await this.fetchPayment(this.$route.params.id)
|
let response = await this.fetchPayment(this.$route.params.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user