fix(admin): send only edit-form fields when saving a customer
Stop cloning the table row into the PUT body so wallet and last-seen are not written back. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -661,7 +661,19 @@ let editId: number | undefined = undefined
|
||||
async function edit(record: Customer) {
|
||||
addUserVisible.value = true
|
||||
editId = record.id
|
||||
form.value = cloneDeep(record)
|
||||
form.value = {
|
||||
fname: record.fname,
|
||||
lname: record.lname,
|
||||
mobile: record.mobile,
|
||||
password: '',
|
||||
birth_date: record.birth_date,
|
||||
phone_number: record.phone_number,
|
||||
province: record.province,
|
||||
city: record.city,
|
||||
n_code: record.n_code,
|
||||
add_user_limit: record.add_user_limit,
|
||||
referral_to_id: record.referral_to_id,
|
||||
}
|
||||
}
|
||||
|
||||
//add
|
||||
@@ -1005,7 +1017,23 @@ async function ok() {
|
||||
loading.value = true
|
||||
try {
|
||||
if (editId) {
|
||||
await updateCustomer(editId, form.value)
|
||||
const payload: Partial<Customer> = {
|
||||
fname: form.value.fname,
|
||||
lname: form.value.lname,
|
||||
mobile: form.value.mobile,
|
||||
birth_date: form.value.birth_date,
|
||||
phone_number: form.value.phone_number,
|
||||
province: form.value.province,
|
||||
city: form.value.city,
|
||||
n_code: form.value.n_code,
|
||||
add_user_limit: form.value.add_user_limit,
|
||||
referral_to_id: form.value.referral_to_id,
|
||||
}
|
||||
const password = String(form.value.password || '').trim()
|
||||
if (password !== '') {
|
||||
payload.password = password
|
||||
}
|
||||
await updateCustomer(editId, payload as Customer)
|
||||
} else {
|
||||
await createCustomer(form.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user