mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(onboarding): recalculate progress bar from full STEP_ORDER position
This commit is contained in:
@@ -2,19 +2,28 @@
|
|||||||
|
|
||||||
import { useOnboarding } from "@onboardjs/react";
|
import { useOnboarding } from "@onboardjs/react";
|
||||||
import { Progress } from "@/components/ui/progress";
|
import { Progress } from "@/components/ui/progress";
|
||||||
|
import { STEP_ORDER } from "@/features/onboarding/constants/steps";
|
||||||
|
|
||||||
export const OnboardingStepper = () => {
|
export const OnboardingStepper = () => {
|
||||||
const { state } = useOnboarding();
|
const { state } = useOnboarding();
|
||||||
|
|
||||||
if (!state) return null;
|
if (!state) return null;
|
||||||
|
|
||||||
|
const currentId = String(state.currentStep?.id ?? "");
|
||||||
|
const currentIndex = Math.max(0, STEP_ORDER.indexOf(currentId));
|
||||||
|
const totalSteps = STEP_ORDER.length;
|
||||||
|
const stepNumber = currentIndex + 1;
|
||||||
|
const progress = Math.round((currentIndex / (totalSteps - 1)) * 100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2 w-full">
|
<div className="flex flex-col gap-2 w-full">
|
||||||
<div className="flex justify-between text-xs text-muted-foreground">
|
<div className="flex justify-between text-xs text-muted-foreground">
|
||||||
<span>Step {state.currentStepNumber} of {state.totalSteps}</span>
|
<span>
|
||||||
<span>{Math.round(state.progressPercentage)}%</span>
|
Step {stepNumber} of {totalSteps}
|
||||||
|
</span>
|
||||||
|
<span>{progress}%</span>
|
||||||
</div>
|
</div>
|
||||||
<Progress value={state.progressPercentage} />
|
<Progress value={progress} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user