'use client'; import { type LearningMiniAppProps, type LearningView, useLearningProgress, ViewTabs, } from '@contractspec/example.learning-journey-ui-shared'; import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card'; import { useCallback, useState } from 'react'; import { Overview } from './views/Overview'; import { Progress } from './views/Progress'; import { Steps } from './views/Steps'; import { Timeline } from './views/Timeline'; type GamifiedMiniAppProps = Omit & { progress?: LearningMiniAppProps['progress']; }; export function GamifiedMiniApp({ track, progress: externalProgress, onStepComplete: externalOnStepComplete, onViewChange, initialView = 'overview', }: GamifiedMiniAppProps) { const [currentView, setCurrentView] = useState(initialView); // Use internal progress if not provided externally const { progress: internalProgress, completeStep: internalCompleteStep } = useLearningProgress(track); const progress = externalProgress ?? internalProgress; const handleViewChange = useCallback( (view: LearningView) => { setCurrentView(view); onViewChange?.(view); }, [onViewChange] ); const handleStepComplete = useCallback( (stepId: string) => { if (externalOnStepComplete) { externalOnStepComplete(stepId); } else { internalCompleteStep(stepId); } }, [externalOnStepComplete, internalCompleteStep] ); const handleStartFromOverview = useCallback(() => { setCurrentView('steps'); onViewChange?.('steps'); }, [onViewChange]); const renderView = () => { const viewProps = { track, progress, onStepComplete: handleStepComplete, }; switch (currentView) { case 'overview': return ; case 'steps': return ; case 'progress': return ; case 'timeline': return ; default: return ; } }; return (
{/* Navigation */} {/* Current View */} {renderView()}
); }