import React, { useState } from 'react'; import { Box } from '@mui/material'; import 'tldraw/tldraw.css'; import { CCPdfEditor } from './CCPdfEditor'; import { CCPdfPicker } from './CCPdfPicker'; import { ExamPdfState } from './types'; import './cc-exam-marker.css'; import { HEADER_HEIGHT } from '../../Layout'; import { CCPanel } from '../../../utils/tldraw/ui-overrides/components/CCPanel'; export const CCExamMarker = () => { const [state, setState] = useState({ phase: 'pick' }); const [view, setView] = useState<'exam-and-markscheme' | 'student-responses'>('exam-and-markscheme'); const [currentStudentIndex, setCurrentStudentIndex] = useState(0); const [isExpanded, setIsExpanded] = useState(false); const [isPinned, setIsPinned] = useState(false); const handleViewChange = (newView: 'exam-and-markscheme' | 'student-responses') => { setView(newView); }; const handleNextStudent = () => { if (state.phase === 'edit' && 'studentResponses' in state && 'examPaper' in state) { const totalStudents = Math.floor(state.studentResponses.pages.length / state.examPaper.pages.length); if (currentStudentIndex < totalStudents - 1) { setCurrentStudentIndex(prev => prev + 1); } } }; const handlePreviousStudent = () => { if (currentStudentIndex > 0) { setCurrentStudentIndex(prev => prev - 1); } }; return ( {state.phase === 'pick' ? ( setState({ phase: 'edit', examPaper: pdfs.examPaper, markScheme: pdfs.markScheme, studentResponses: pdfs.studentResponses, }) } /> ) : ( { if (!editor) return null; const examMarkerProps = { editor, currentView: view, onViewChange: handleViewChange, currentStudentIndex, totalStudents: Math.floor(state.studentResponses.pages.length / state.examPaper.pages.length), onPreviousStudent: handlePreviousStudent, onNextStudent: handleNextStudent, getCurrentPdf: () => { if (!editor) return null; const currentPageId = editor.getCurrentPageId(); if (currentPageId.includes('exam-page')) { return state.examPaper; } else if (currentPageId.includes('mark-scheme-page')) { return state.markScheme; } else if (currentPageId.includes('student-response')) { return state.studentResponses; } return null; }, }; return ; }} /> )} ); };