Fix 'Mapping already exists' error on second save
After createMapping, the new mapping's id was not stored in allValues state, so editing the row again fell into the create path instead of update. Now stores created.id so subsequent saves correctly use updateMapping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
37a6645af0
commit
10dc92b45e
@ -130,14 +130,14 @@ export default function Mappings({ source }) {
|
|||||||
valueKey(x.extracted_value) === k ? { ...x, output: updated.output } : x
|
valueKey(x.extracted_value) === k ? { ...x, output: updated.output } : x
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
await api.createMapping({
|
const created = await api.createMapping({
|
||||||
source_name: source,
|
source_name: source,
|
||||||
rule_name: row.rule_name,
|
rule_name: row.rule_name,
|
||||||
input_value: row.extracted_value,
|
input_value: row.extracted_value,
|
||||||
output
|
output
|
||||||
})
|
})
|
||||||
setAllValues(av => av.map(x =>
|
setAllValues(av => av.map(x =>
|
||||||
valueKey(x.extracted_value) === k ? { ...x, is_mapped: true, output } : x
|
valueKey(x.extracted_value) === k ? { ...x, is_mapped: true, mapping_id: created.id, output } : x
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
setDrafts(d => { const n = { ...d }; delete n[k]; return n })
|
setDrafts(d => { const n = { ...d }; delete n[k]; return n })
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user