'use client' import React, { useState } from 'react' import Link from 'next/link' import { useRouter } from 'next/navigation' import { useSDK, getStepById, getNextStep, getPreviousStep, SDK_STEPS } from '@/lib/sdk' import { STEP_EXPLANATIONS } from './StepExplanations' // ============================================================================= // TYPES // ============================================================================= export interface StepTip { icon: 'info' | 'warning' | 'success' | 'lightbulb' title: string description: string } interface StepHeaderProps { stepId: string title?: string description?: string explanation?: string tips?: StepTip[] showNavigation?: boolean showProgress?: boolean onComplete?: () => void isCompleted?: boolean children?: React.ReactNode } // ============================================================================= // ICONS // ============================================================================= const icons = { info: ( ), warning: ( ), success: ( ), lightbulb: ( ), arrowLeft: ( ), arrowRight: ( ), check: ( ), help: ( ), } const tipColors = { info: 'bg-blue-50 border-blue-200 text-blue-800', warning: 'bg-amber-50 border-amber-200 text-amber-800', success: 'bg-green-50 border-green-200 text-green-800', lightbulb: 'bg-purple-50 border-purple-200 text-purple-800', } const tipIconColors = { info: 'text-blue-500', warning: 'text-amber-500', success: 'text-green-500', lightbulb: 'text-purple-500', } // ============================================================================= // STEP HEADER COMPONENT // ============================================================================= export function StepHeader({ stepId, title: titleProp, description: descriptionProp, explanation: explanationProp, tips: tipsProp, showNavigation = true, showProgress = true, onComplete, isCompleted = false, children, }: StepHeaderProps) { const router = useRouter() const { state, dispatch } = useSDK() const [showHelp, setShowHelp] = useState(false) // Look up defaults from STEP_EXPLANATIONS when props are not provided const preset = STEP_EXPLANATIONS[stepId as keyof typeof STEP_EXPLANATIONS] const title = titleProp ?? preset?.title ?? stepId const description = descriptionProp ?? preset?.description ?? '' const explanation = explanationProp ?? preset?.explanation ?? '' const tips = tipsProp ?? preset?.tips ?? [] const currentStep = getStepById(stepId) const prevStep = getPreviousStep(stepId) const nextStep = getNextStep(stepId) const stepCompleted = state.completedSteps.includes(stepId) const handleComplete = () => { if (onComplete) { onComplete() } dispatch({ type: 'COMPLETE_STEP', payload: stepId }) if (nextStep) { router.push(nextStep.url) } } const handleSkip = () => { if (nextStep) { router.push(nextStep.url) } } // Calculate step progress within phase const phaseSteps = currentStep ? SDK_STEPS.filter(s => s.phase === currentStep.phase).length : 0 const stepNumber = currentStep?.order || 0 return (
{description}
{explanation}
{tip.description}