1
0
forked from test/crm

fix: update onboarding status when first email is sent

This commit is contained in:
Shariq Ansari 2025-03-12 18:13:57 +05:30
parent a1e6504740
commit 41c65eb777
3 changed files with 39 additions and 19 deletions

View File

@ -20,7 +20,7 @@ def update_user_onboarding_status(steps: str):
@frappe.whitelist()
def get_first_non_converted_lead():
def get_first_lead():
lead = frappe.get_all(
"CRM Lead",
filters={"converted": 0},

View File

@ -227,6 +227,7 @@ async function submitEmail() {
reload.value = true
emit('scroll')
capture('email_sent', { doctype: props.doctype })
updateOnboardingStep('send_first_email')
}
async function submitComment() {

View File

@ -55,12 +55,10 @@ const steps = reactive([
onClick: async () => {
minimize.value = true
firstLead.value =
!firstLead.value &&
(await call('crm.api.onboarding.get_first_non_converted_lead'))
let lead = await getFirstLead()
if (firstLead.value) {
router.push({ name: 'Lead', params: { leadId: firstLead.value } })
if (lead) {
router.push({ name: 'Lead', params: { leadId: lead } })
} else {
router.push({ name: 'Leads' })
}
@ -73,13 +71,12 @@ const steps = reactive([
completed: false,
onClick: async () => {
minimize.value = true
firstDeal.value =
!firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
let deal = await getFirstDeal()
if (firstDeal.value) {
if (deal) {
router.push({
name: 'Deal',
params: { dealId: firstDeal.value },
params: { dealId: deal },
hash: '#tasks',
})
} else {
@ -94,13 +91,12 @@ const steps = reactive([
completed: false,
onClick: async () => {
minimize.value = true
firstDeal.value =
!firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
let deal = await getFirstDeal()
if (firstDeal.value) {
if (deal) {
router.push({
name: 'Deal',
params: { dealId: firstDeal.value },
params: { dealId: deal },
hash: '#notes',
})
} else {
@ -115,13 +111,12 @@ const steps = reactive([
completed: false,
onClick: async () => {
minimize.value = true
firstDeal.value =
!firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
let deal = await getFirstDeal()
if (firstDeal.value) {
if (deal) {
router.push({
name: 'Deal',
params: { dealId: firstDeal.value },
params: { dealId: deal },
hash: '#comments',
})
} else {
@ -130,10 +125,24 @@ const steps = reactive([
},
},
{
name: 'send_email',
name: 'send_first_email',
title: 'Send email',
icon: markRaw(EmailIcon),
completed: false,
onClick: async () => {
minimize.value = true
let deal = await getFirstDeal()
if (deal) {
router.push({
name: 'Deal',
params: { dealId: deal },
hash: '#emails',
})
} else {
router.push({ name: 'Leads' })
}
},
},
{
name: 'change_deal_status',
@ -143,6 +152,16 @@ const steps = reactive([
},
])
async function getFirstLead() {
if (firstLead.value) return firstLead.value
return await call('crm.api.onboarding.get_first_lead')
}
async function getFirstDeal() {
if (firstDeal.value) return firstDeal.value
return await call('crm.api.onboarding.get_first_deal')
}
const stepsCompleted = computed(
() => steps.filter((step) => step.completed).length,
)