From a3f438e2435b8e53e39cd571accbad65da5cf66b Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 13 Jul 2026 22:40:20 -0700 Subject: [PATCH] feat: make ItemModal stage dropdown direction-aware for outbound leads --- frontend/src/components/ItemModal.vue | 5 +++++ frontend/tests/ItemModal.spec.js | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/frontend/src/components/ItemModal.vue b/frontend/src/components/ItemModal.vue index a1e406a..2be0896 100644 --- a/frontend/src/components/ItemModal.vue +++ b/frontend/src/components/ItemModal.vue @@ -13,6 +13,10 @@ const followUpDate = ref('') const DONATION_STAGES = ['new', 'replied', 'pickup_scheduled', 'picked_up', 'logged_in_bookmark'] const OTHER_STAGES = ['new', 'done'] +const OUTBOUND_STAGES = [ + 'new', 'reviewed', 'outreach_drafted', 'outreach_sent', + 'replied', 'pickup_scheduled', 'picked_up', 'logged_in_bookmark', +] watch(() => props.item, (item) => { if (!item) return @@ -24,6 +28,7 @@ watch(() => props.item, (item) => { }, { immediate: true }) function stagesForType() { + if (props.item?.direction === 'outbound') return OUTBOUND_STAGES if (type.value === 'donation') return DONATION_STAGES if (type.value === 'other') return OTHER_STAGES return ['new'] diff --git a/frontend/tests/ItemModal.spec.js b/frontend/tests/ItemModal.spec.js index 855f68b..c3131a6 100644 --- a/frontend/tests/ItemModal.spec.js +++ b/frontend/tests/ItemModal.spec.js @@ -16,6 +16,7 @@ function makeItem(overrides = {}) { stage: 'new', notes: '', follow_up_date: '', + direction: 'inbound', ...overrides, } } @@ -53,4 +54,28 @@ describe('ItemModal', () => { expect(wrapper.findAll('select')[1].element.value).toBe('new') }) + + it('offers outbound stages when item.direction is outbound, regardless of type', () => { + const wrapper = mount(ItemModal, { + props: { item: makeItem({ direction: 'outbound', type: 'donation', stage: 'new' }) }, + }) + const options = wrapper.findAll('select')[1].findAll('option').map((o) => o.element.value) + expect(options).toEqual([ + 'new', 'reviewed', 'outreach_drafted', 'outreach_sent', + 'replied', 'pickup_scheduled', 'picked_up', 'logged_in_bookmark', + ]) + }) + + it('does not reset an outbound item stage when type changes', async () => { + const wrapper = mount(ItemModal, { + props: { item: makeItem({ direction: 'outbound', type: 'donation', stage: 'outreach_sent' }) }, + }) + const stageSelect = wrapper.findAll('select')[1] + expect(stageSelect.element.value).toBe('outreach_sent') + + const typeSelect = wrapper.findAll('select')[0] + await typeSelect.setValue('other') + + expect(wrapper.findAll('select')[1].element.value).toBe('outreach_sent') + }) })