fix: match ItemModal stagesForType() to backend valid_stages_for() contract
stagesForType() returned OTHER_STAGES (including 'done') for the unset type case, but backend stages.py::valid_stages_for(None) only allows ['new'] when type is unset. This let the UI offer 'Done' as a stage option with no type selected, which the backend rejects with 422. Also add a watch on type that resets stage to 'new' when the current stage is no longer valid for the newly selected type, preventing a stale invalid stage from being silently submitted.
This commit is contained in:
parent
13b41cc438
commit
f2709fc425
1 changed files with 9 additions and 1 deletions
|
|
@ -24,9 +24,17 @@ watch(() => props.item, (item) => {
|
|||
}, { immediate: true })
|
||||
|
||||
function stagesForType() {
|
||||
return type.value === 'donation' ? DONATION_STAGES : OTHER_STAGES
|
||||
if (type.value === 'donation') return DONATION_STAGES
|
||||
if (type.value === 'other') return OTHER_STAGES
|
||||
return ['new']
|
||||
}
|
||||
|
||||
watch(type, () => {
|
||||
if (!stagesForType().includes(stage.value)) {
|
||||
stage.value = 'new'
|
||||
}
|
||||
})
|
||||
|
||||
async function save() {
|
||||
const updated = await updateItem(props.item.id, {
|
||||
sender_id: senderId.value || null,
|
||||
|
|
|
|||
Loading…
Reference in a new issue