/**
* src/book/components/Checkpoint.tsx
*
* End-of-chapter block: wraps a set of quiz items and/or challenge prompts.
* Completing it (all quizzes answered correctly) marks the chapter done
* in localStorage via the progress store.
*
* Usage in MDX:
*
* Run the hello-hoop program, change one number, and re-run it.
*
*/
import { type ReactNode } from 'react';
import { markChapterDone } from '../lib/progress.ts';
interface Props {
chapterId: string;
children?: ReactNode;
/** Called when the user clicks "Mark complete". */
onComplete?: () => void;
}
import { useState } from 'react';
export default function Checkpoint({ chapterId, children, onComplete }: Props) {
const [done, setDone] = useState(false);
const handleComplete = () => {
markChapterDone(chapterId);
setDone(true);
onComplete?.();
};
return (