import { useState, ReactNode } from "react"; import CheckIcon from "@app/assets/images/check-icon.svg"; import "./stepper-styles.scss"; interface Step { title: string; header: string; action: { label: string; url: string; icon: ReactNode; target?: string; }; content: ReactNode; isDone?: boolean; } interface StepperProps { steps: Step[]; } export default function Stepper({ steps = [] }: StepperProps) { const safeSteps = Array.isArray(steps) ? steps : []; const firstIncompleteIndex = safeSteps.findIndex((step) => !step.isDone); const [currentStep, setCurrentStep] = useState(() => { if (firstIncompleteIndex !== -1) { return firstIncompleteIndex; } else if (safeSteps.length > 0) { return safeSteps.length - 1; } else { return 0; } }); // If no steps are provided, show a message if (safeSteps.length === 0) { return
No steps provided
; } return (
{safeSteps.map((step, index) => (
{index < safeSteps.length - 1 &&
} {step.isDone ? ( Check Icon ) : (
)}
{step.title}
))}

{safeSteps[currentStep]?.header}

{safeSteps[currentStep]?.content ||
No content available
}
{safeSteps[currentStep]?.action.label ?? "Done"} {safeSteps[currentStep]?.action.icon && (
{safeSteps[currentStep]?.action.icon}
)}
); }