1
0
forked from test/crm

fix: skip onboarding step

This commit is contained in:
Shariq Ansari 2025-03-12 19:56:16 +05:30
parent 2131b048d9
commit a42eb6b99e
2 changed files with 29 additions and 10 deletions

View File

@ -21,14 +21,24 @@
<div
v-for="step in steps"
:key="step.title"
class="w-full flex gap-2 items-center hover:bg-surface-gray-1 rounded px-2 py-1.5 cursor-pointer"
:class="[
step.completed ? 'text-ink-gray-5 line-through' : 'text-ink-gray-8',
]"
@click="() => !step.completed && step.onClick()"
class="group w-full flex gap-2 justify-between items-center hover:bg-surface-gray-1 rounded px-2 py-1.5 cursor-pointer"
@click.stop="() => !step.completed && step.onClick()"
>
<component :is="step.icon" class="h-4" />
<div class="text-base">{{ step.title }}</div>
<div
class="flex gap-2 items-center"
:class="[step.completed ? 'text-ink-gray-5' : 'text-ink-gray-8']"
>
<component :is="step.icon" class="h-4" />
<div class="text-base" :class="{ 'line-through': step.completed }">
{{ step.title }}
</div>
</div>
<Button
v-if="!step.completed"
:label="__('Skip')"
class="!h-4 text-xs !text-ink-gray-6 hidden group-hover:flex"
@click="() => skip(step.name)"
/>
</div>
</div>
</div>
@ -39,6 +49,6 @@ import { useOnboarding } from '@/composables/onboarding'
const emit = defineEmits(['close'])
const { steps, stepsCompleted, totalSteps, completedPercentage } =
const { steps, stepsCompleted, totalSteps, completedPercentage, skip } =
useOnboarding()
</script>

View File

@ -190,7 +190,7 @@ export function useOnboarding() {
syncStatus()
function updateOnboardingStep(step) {
function updateOnboardingStep(step, skipped = false) {
if (isOnboardingStepsCompleted.value) return
let user = window.user
if (!user) return false
@ -212,13 +212,21 @@ export function useOnboarding() {
window.user = user
capture('onboarding_' + step)
if (skipped) {
capture('onboarding_skipped_' + step)
} else {
capture('onboarding_' + step)
}
call('crm.api.onboarding.update_user_onboarding_status', {
steps: JSON.stringify(_steps),
})
}
function skip(step) {
updateOnboardingStep(step, true)
}
function syncStatus() {
if (isOnboardingStepsCompleted.value) return
let user = window.user
@ -241,5 +249,6 @@ export function useOnboarding() {
totalSteps,
completedPercentage,
updateOnboardingStep,
skip,
}
}