feat: make ItemModal stage dropdown direction-aware for outbound leads

This commit is contained in:
pyr0ball 2026-07-13 22:40:20 -07:00
parent 4dbda85ccd
commit a3f438e243
2 changed files with 30 additions and 0 deletions

View file

@ -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']

View file

@ -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')
})
})