fix: check onboarding status from boot to show/hide getting started banner

This commit is contained in:
Shariq Ansari 2025-03-12 15:59:50 +05:30
parent 65425a325f
commit f877a53918
2 changed files with 22 additions and 10 deletions

View File

@ -141,12 +141,14 @@ import {
unreadNotificationsCount, unreadNotificationsCount,
notificationsStore, notificationsStore,
} from '@/stores/notifications' } from '@/stores/notifications'
import { useOnboarding } from '@/composables/onboarding'
import { FeatherIcon, TrialBanner } from 'frappe-ui' import { FeatherIcon, TrialBanner } from 'frappe-ui'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
import { ref, computed, h } from 'vue' import { ref, computed, h } from 'vue'
const { getPinnedViews, getPublicViews } = viewsStore() const { getPinnedViews, getPublicViews } = viewsStore()
const { toggle: toggleNotificationPanel } = notificationsStore() const { toggle: toggleNotificationPanel } = notificationsStore()
const { checkOnboardingStatus } = useOnboarding()
const isSidebarCollapsed = useStorage('isSidebarCollapsed', false) const isSidebarCollapsed = useStorage('isSidebarCollapsed', false)
@ -259,7 +261,7 @@ function getIcon(routeName, icon) {
const isOnboardingStepsCompleted = useStorage( const isOnboardingStepsCompleted = useStorage(
'isOnboardingStepsCompleted', 'isOnboardingStepsCompleted',
false, checkOnboardingStatus(),
) )
const showHelpModal = ref(false) const showHelpModal = ref(false)
</script> </script>

View File

@ -10,41 +10,49 @@ import { ref, reactive, computed, markRaw } from 'vue'
const steps = reactive([ const steps = reactive([
{ {
name: 'create_first_lead',
title: 'Create your first lead', title: 'Create your first lead',
icon: markRaw(LeadsIcon), icon: markRaw(LeadsIcon),
completed: true, completed: false,
}, },
{ {
name: 'invite_your_team',
title: 'Invite your team', title: 'Invite your team',
icon: markRaw(InviteIcon), icon: markRaw(InviteIcon),
completed: false, completed: false,
}, },
{ {
name: 'convert_lead_to_deal',
title: 'Convert lead to deal', title: 'Convert lead to deal',
icon: markRaw(ConvertIcon), icon: markRaw(ConvertIcon),
completed: false, completed: false,
}, },
{ {
name: 'create_first_note',
title: 'Create your first note', title: 'Create your first note',
icon: markRaw(NoteIcon), icon: markRaw(NoteIcon),
completed: false, completed: false,
}, },
{ {
name: 'create_first_task',
title: 'Create your first task', title: 'Create your first task',
icon: markRaw(TaskIcon), icon: markRaw(TaskIcon),
completed: false, completed: false,
}, },
{ {
name: 'add_first_comment',
title: 'Add your first comment', title: 'Add your first comment',
icon: markRaw(CommentIcon), icon: markRaw(CommentIcon),
completed: false, completed: false,
}, },
{ {
name: 'send_email',
title: 'Send email', title: 'Send email',
icon: markRaw(EmailIcon), icon: markRaw(EmailIcon),
completed: false, completed: false,
}, },
{ {
name: 'change_deal_status',
title: 'Change deal status', title: 'Change deal status',
icon: markRaw(StepsIcon), icon: markRaw(StepsIcon),
completed: false, completed: false,
@ -61,12 +69,15 @@ const completedPercentage = computed(() =>
) )
export function useOnboarding() { export function useOnboarding() {
const incrementStep = () => { function checkOnboardingStatus() {
stepsCompleted.value++ let user = window.user
} if (!user) return false
if (user.onboarding_status['frappe_crm_onboarding_status']) {
const decrementStep = () => { return user.onboarding_status['frappe_crm_onboarding_status'].every(
stepsCompleted.value-- (step) => step.completed,
)
}
return false
} }
return { return {
@ -74,7 +85,6 @@ export function useOnboarding() {
stepsCompleted, stepsCompleted,
totalSteps, totalSteps,
completedPercentage, completedPercentage,
incrementStep, checkOnboardingStatus,
decrementStep,
} }
} }