diff --git a/client/package.json b/client/package.json index 7bb93451..859e958d 100644 --- a/client/package.json +++ b/client/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "cross-env": "^10.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1" @@ -13,7 +14,7 @@ "typescript": "^4.9.5" }, "scripts": { - "start": "PORT=3004 react-scripts start", + "start": "cross-env PORT=3004 react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" @@ -36,4 +37,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/client/src/components/Evaluations.tsx b/client/src/components/Evaluations.tsx index 1b992a1d..52f620c4 100644 --- a/client/src/components/Evaluations.tsx +++ b/client/src/components/Evaluations.tsx @@ -4,6 +4,7 @@ import ClassService from '../services/ClassService'; import EnrollmentService from '../services/EnrollmentService'; import { ImportGradeComponent } from './ImportGrade'; +import InfoButton from './InfoButton'; interface EvaluationsProps { onError: (errorMessage: string) => void; @@ -21,7 +22,7 @@ const Evaluations: React.FC = ({ onError }) => { // Predefined evaluation goals const evaluationGoals = [ 'Requirements', - 'Configuration Management', + 'Configuration Management', 'Project Management', 'Design', 'Tests', @@ -40,6 +41,17 @@ const Evaluations: React.FC = ({ onError }) => { } }, [onError]); + const [discrepancies, setDiscrepancies] = useState([]); + + const loadDiscrepancies = useCallback(async (classId: string) => { + try { + const data = await EnrollmentService.getDiscrepancys(classId); + setDiscrepancies(data); + } catch (error) { + onError(`Failed to load discrepancies: ${(error as Error).message}`); + } + }, [onError]); + // Load all classes on component mount useEffect(() => { loadClasses(); @@ -50,10 +62,11 @@ const Evaluations: React.FC = ({ onError }) => { if (selectedClassId) { const classObj = classes.find(c => c.id === selectedClassId); setSelectedClass(classObj || null); + loadDiscrepancies(selectedClassId); // CARREGAR DISCREPÂNCIAS QUANDO A TURMA É SELECIONADA } else { setSelectedClass(null); } - }, [selectedClassId, classes]); + }, [selectedClassId, classes, loadDiscrepancies]); const handleClassSelection = (classId: string) => { setSelectedClassId(classId); @@ -75,6 +88,7 @@ const Evaluations: React.FC = ({ onError }) => { await EnrollmentService.updateEvaluation(selectedClass.id, studentCPF, goal, grade); // Reload classes to get updated enrollment data await loadClasses(); + await loadDiscrepancies(selectedClass.id); // RECARREGAR DISCREPÂNCIAS QUANDO UMA NOTA É ALTERADA } catch (error) { onError(`Failed to update evaluation: ${(error as Error).message}`); } @@ -94,7 +108,7 @@ const Evaluations: React.FC = ({ onError }) => { return (

Evaluations

- + {/* Class Selection */}
@@ -114,10 +128,10 @@ const Evaluations: React.FC = ({ onError }) => {
{!selectedClass && ( -
= ({ onError }) => { )} {selectedClass && selectedClass.enrollments.length === 0 && ( -
= ({ onError }) => {

{selectedClass.topic} ({selectedClass.year}/{selectedClass.semester})

- +
@@ -163,19 +177,28 @@ const Evaluations: React.FC = ({ onError }) => { {selectedClass.enrollments.map(enrollment => { const student = enrollment.student; - + // Create a map of evaluations for quick lookup const studentEvaluations = enrollment.evaluations.reduce((acc, evaluation) => { acc[evaluation.goal] = evaluation.grade; return acc; - }, {} as {[goal: string]: string}); + }, {} as { [goal: string]: string }); return ( - + {evaluationGoals.map(goal => { const currentGrade = studentEvaluations[goal] || ''; - + return (
{student.name}{student.name} + { } + {(() => { + const disc = discrepancies.find(d => d.studentCPF === student.cpf); + if (disc) { + + } + return null; + })()} +