"use client"; import { useEffect, useState } from "react"; import { useOnboarding } from "@onboardjs/react"; import { Button } from "@/components/ui/button"; import { OnboardingStepper } from "@/features/onboarding/onboarding-stepper"; import { OnboardingChecklist } from "@/features/onboarding/onboarding-checklist"; import { Heart } from "lucide-react"; import { AuthLogoSection } from "../auth/auth-logo-section"; import { STEP_ORDER } from "@/features/onboarding/constants/steps"; export const OnboardingShell = () => { const { state, previous, skip, next, renderStep } = useOnboarding(); const currentStepId = String(state?.currentStep?.id ?? ""); const currentIndex = STEP_ORDER.indexOf(currentStepId); const [latestIndex, setLatestIndex] = useState(currentIndex); useEffect(() => { setLatestIndex((prev) => Math.max(prev, currentIndex)); }, [currentIndex]); if (!state) return null; const showSplit = currentStepId !== "agent-waiting" && currentStepId !== "finish"; const isGoingBack = currentIndex < latestIndex; // Steps that are one-way: disable Back both when ON them and when they'd be the destination const BLOCKED_STEPS = ["login", "account-info", "security"]; const prevStepId = STEP_ORDER[currentIndex - 1] ?? ""; const canGoBack = !BLOCKED_STEPS.includes(currentStepId) && !BLOCKED_STEPS.includes(prevStepId) && currentIndex > 0; return (
{renderStep()}
{state.isSkippable && ( )} {isGoingBack && ( )}
{showSplit && (
)}
); };