From f2709fc425cbeb235e51340179513d3d797913c1 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 13 Jul 2026 14:25:28 -0700 Subject: [PATCH] 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. --- frontend/src/components/ItemModal.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ItemModal.vue b/frontend/src/components/ItemModal.vue index 247294c..a1e406a 100644 --- a/frontend/src/components/ItemModal.vue +++ b/frontend/src/components/ItemModal.vue @@ -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,