fix: update onboarding status when first comment is added

This commit is contained in:
Shariq Ansari 2025-03-12 17:39:31 +05:30
parent 11790586da
commit a1e6504740
2 changed files with 45 additions and 15 deletions

View File

@ -4,7 +4,9 @@
<Button <Button
ref="sendEmailRef" ref="sendEmailRef"
variant="ghost" variant="ghost"
:class="[showEmailBox ? '!bg-surface-gray-4 hover:!bg-surface-gray-3' : '']" :class="[
showEmailBox ? '!bg-surface-gray-4 hover:!bg-surface-gray-3' : '',
]"
:label="__('Reply')" :label="__('Reply')"
@click="toggleEmailBox()" @click="toggleEmailBox()"
> >
@ -15,7 +17,9 @@
<Button <Button
variant="ghost" variant="ghost"
:label="__('Comment')" :label="__('Comment')"
:class="[showCommentBox ? '!bg-surface-gray-4 hover:!bg-surface-gray-3' : '']" :class="[
showCommentBox ? '!bg-surface-gray-4 hover:!bg-surface-gray-3' : '',
]"
@click="toggleCommentBox()" @click="toggleCommentBox()"
> >
<template #prefix> <template #prefix>
@ -90,6 +94,7 @@ import CommentIcon from '@/components/Icons/CommentIcon.vue'
import Email2Icon from '@/components/Icons/Email2Icon.vue' import Email2Icon from '@/components/Icons/Email2Icon.vue'
import { capture } from '@/telemetry' import { capture } from '@/telemetry'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
import { useOnboarding } from '@/composables/onboarding'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
import { call, createResource } from 'frappe-ui' import { call, createResource } from 'frappe-ui'
import { ref, watch, computed } from 'vue' import { ref, watch, computed } from 'vue'
@ -107,6 +112,7 @@ const reload = defineModel('reload')
const emit = defineEmits(['scroll']) const emit = defineEmits(['scroll'])
const { getUser } = usersStore() const { getUser } = usersStore()
const { updateOnboardingStep } = useOnboarding()
const showEmailBox = ref(false) const showEmailBox = ref(false)
const showCommentBox = ref(false) const showCommentBox = ref(false)
@ -152,7 +158,7 @@ watch(
editor.commands.focus() editor.commands.focus()
setSignature(editor) setSignature(editor)
} }
} },
) )
watch( watch(
@ -161,7 +167,7 @@ watch(
if (value) { if (value) {
newCommentEditor.value.editor.commands.focus() newCommentEditor.value.editor.commands.focus()
} }
} },
) )
const commentEmpty = computed(() => { const commentEmpty = computed(() => {
@ -231,6 +237,7 @@ async function submitComment() {
reload.value = true reload.value = true
emit('scroll') emit('scroll')
capture('comment_sent', { doctype: props.doctype }) capture('comment_sent', { doctype: props.doctype })
updateOnboardingStep('add_first_comment')
} }
function toggleEmailBox() { function toggleEmailBox() {

View File

@ -22,6 +22,9 @@ export const isOnboardingStepsCompleted = useStorage(
false, false,
) )
const firstLead = ref('')
const firstDeal = ref('')
const steps = reactive([ const steps = reactive([
{ {
name: 'create_first_lead', name: 'create_first_lead',
@ -52,11 +55,12 @@ const steps = reactive([
onClick: async () => { onClick: async () => {
minimize.value = true minimize.value = true
let leadName = await call( firstLead.value =
'crm.api.onboarding.get_first_non_converted_lead', !firstLead.value &&
) (await call('crm.api.onboarding.get_first_non_converted_lead'))
if (leadName) {
router.push({ name: 'Lead', params: { leadId: leadName } }) if (firstLead.value) {
router.push({ name: 'Lead', params: { leadId: firstLead.value } })
} else { } else {
router.push({ name: 'Leads' }) router.push({ name: 'Leads' })
} }
@ -69,11 +73,13 @@ const steps = reactive([
completed: false, completed: false,
onClick: async () => { onClick: async () => {
minimize.value = true minimize.value = true
let dealName = await call('crm.api.onboarding.get_first_deal') firstDeal.value =
if (dealName) { !firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
if (firstDeal.value) {
router.push({ router.push({
name: 'Deal', name: 'Deal',
params: { dealId: dealName }, params: { dealId: firstDeal.value },
hash: '#tasks', hash: '#tasks',
}) })
} else { } else {
@ -88,11 +94,13 @@ const steps = reactive([
completed: false, completed: false,
onClick: async () => { onClick: async () => {
minimize.value = true minimize.value = true
let dealName = await call('crm.api.onboarding.get_first_deal') firstDeal.value =
if (dealName) { !firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
if (firstDeal.value) {
router.push({ router.push({
name: 'Deal', name: 'Deal',
params: { dealId: dealName }, params: { dealId: firstDeal.value },
hash: '#notes', hash: '#notes',
}) })
} else { } else {
@ -105,6 +113,21 @@ const steps = reactive([
title: 'Add your first comment', title: 'Add your first comment',
icon: markRaw(CommentIcon), icon: markRaw(CommentIcon),
completed: false, completed: false,
onClick: async () => {
minimize.value = true
firstDeal.value =
!firstDeal.value && (await call('crm.api.onboarding.get_first_deal'))
if (firstDeal.value) {
router.push({
name: 'Deal',
params: { dealId: firstDeal.value },
hash: '#comments',
})
} else {
router.push({ name: 'Leads' })
}
},
}, },
{ {
name: 'send_email', name: 'send_email',