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() @frappe.whitelist()
def get_first_non_converted_lead(): def get_first_lead():
lead = frappe.get_all( lead = frappe.get_all(
"CRM Lead", "CRM Lead",
filters={"converted": 0}, filters={"converted": 0},

View File

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

View File

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