fix(constructeurs): improve search filtering and duplicate prevention
Switch ConstructeurSelect to client-side filtering instead of debounced API calls. Add duplicate name check before creating a new constructeur in both ConstructeurSelect and the constructeurs page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,8 +195,18 @@ const closeModal = () => {
|
||||
}
|
||||
|
||||
const saveConstructeur = async () => {
|
||||
const trimmedName = form.value.name.trim()
|
||||
const duplicate = constructeurs.value.find(
|
||||
(c) => c.name.toLowerCase() === trimmedName.toLowerCase()
|
||||
&& c.id !== editingConstructeur.value?.id,
|
||||
)
|
||||
if (duplicate) {
|
||||
showError(`Un fournisseur "${duplicate.name}" existe déjà.`)
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
const payload = { ...form.value }
|
||||
const payload = { ...form.value, name: trimmedName }
|
||||
if (!payload.email) { delete payload.email }
|
||||
if (!payload.phone) { delete payload.phone }
|
||||
let result
|
||||
|
||||
Reference in New Issue
Block a user