feat: make ItemModal stage dropdown direction-aware for outbound leads
This commit is contained in:
parent
4dbda85ccd
commit
a3f438e243
2 changed files with 30 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ const followUpDate = ref('')
|
||||||
|
|
||||||
const DONATION_STAGES = ['new', 'replied', 'pickup_scheduled', 'picked_up', 'logged_in_bookmark']
|
const DONATION_STAGES = ['new', 'replied', 'pickup_scheduled', 'picked_up', 'logged_in_bookmark']
|
||||||
const OTHER_STAGES = ['new', 'done']
|
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) => {
|
watch(() => props.item, (item) => {
|
||||||
if (!item) return
|
if (!item) return
|
||||||
|
|
@ -24,6 +28,7 @@ watch(() => props.item, (item) => {
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
function stagesForType() {
|
function stagesForType() {
|
||||||
|
if (props.item?.direction === 'outbound') return OUTBOUND_STAGES
|
||||||
if (type.value === 'donation') return DONATION_STAGES
|
if (type.value === 'donation') return DONATION_STAGES
|
||||||
if (type.value === 'other') return OTHER_STAGES
|
if (type.value === 'other') return OTHER_STAGES
|
||||||
return ['new']
|
return ['new']
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ function makeItem(overrides = {}) {
|
||||||
stage: 'new',
|
stage: 'new',
|
||||||
notes: '',
|
notes: '',
|
||||||
follow_up_date: '',
|
follow_up_date: '',
|
||||||
|
direction: 'inbound',
|
||||||
...overrides,
|
...overrides,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,4 +54,28 @@ describe('ItemModal', () => {
|
||||||
|
|
||||||
expect(wrapper.findAll('select')[1].element.value).toBe('new')
|
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')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue