From 04c301103b14d51e1ce5badba529562ee251fda9 Mon Sep 17 00:00:00 2001 From: "Deyvi Correa Z." Date: Fri, 13 Sep 2024 17:37:54 -0300 Subject: [PATCH 1/3] --resetPassword --- FrontEnd/react-app/src/App.jsx | 5 +- FrontEnd/react-app/src/components/Login.jsx | 87 +++--- .../src/components/ProtectedRoute.jsx | 48 ++- .../src/components/ResetPassword.jsx | 3 +- .../react-app/src/pages/StudentDashboard.jsx | 274 ++++++++++++------ .../src/pages/student/viewEvaluations.jsx | 113 ++++++++ 6 files changed, 360 insertions(+), 170 deletions(-) create mode 100644 FrontEnd/react-app/src/pages/student/viewEvaluations.jsx diff --git a/FrontEnd/react-app/src/App.jsx b/FrontEnd/react-app/src/App.jsx index e9e8576..ab70ba7 100644 --- a/FrontEnd/react-app/src/App.jsx +++ b/FrontEnd/react-app/src/App.jsx @@ -23,17 +23,14 @@ const App = () => { {/* Ruta para la página de inicio */} } /> - - } /> - } /> - {/* Ruta protegida para los dashboards */} }> } /> } /> } /> + } /> diff --git a/FrontEnd/react-app/src/components/Login.jsx b/FrontEnd/react-app/src/components/Login.jsx index 17f5161..26daa51 100644 --- a/FrontEnd/react-app/src/components/Login.jsx +++ b/FrontEnd/react-app/src/components/Login.jsx @@ -10,82 +10,75 @@ import { useToast, } from "@chakra-ui/react"; import { jwtDecode } from "jwt-decode"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { useNavigate } from "react-router-dom"; import logo from "../assets/logoSchoolManager.png"; import { loginUser } from "../services/authService"; -import { forgotPassword } from "../services/resetService"; // Cambia de resetService a authService +import { forgotPassword } from "../services/resetService"; // Asegúrate de que la ruta del import sea correcta const Login = () => { const [loginData, setLoginData] = useState({ email: "", password: "" }); - const [name, setName] = useState(""); const [isResetting, setIsResetting] = useState(false); const [resetEmail, setResetEmail] = useState(""); const navigate = useNavigate(); const toast = useToast(); const [isLoading, setIsLoading] = useState(false); - useEffect(() => { - const token = sessionStorage.getItem("token"); - if (token) { - try { - const decodedToken = jwtDecode(token); - const authorities = decodedToken.authorities || ""; - - if (authorities.includes("ROLE_TEACHER")) { - navigate("/teacher-dashboard"); - } else if (authorities.includes("ROLE_STUDENT")) { - navigate("/student-dashboard"); - } else if (authorities.includes("ROLE_PARENT")) { - navigate("/parent-dashboard"); - } else if (authorities.includes("ROLE_ADMIN")) { - navigate("/admin"); - } else { - navigate("/"); - } - } catch (error) { - console.error("Error decoding token:", error); - } - } - }, [navigate]); - const handleChange = (e) => { setLoginData({ ...loginData, [e.target.name]: e.target.value }); }; const handleSubmit = async (e) => { e.preventDefault(); + setIsLoading(true); + try { const response = await loginUser(loginData); - console.log(response); - const name = response.name; - const token = response.token; - const decodedToken = jwtDecode(token); - const authorities = decodedToken.authorities || ""; - sessionStorage.setItem("name", name); - let redirectPath = "/"; + if (response.status === false) { + toast({ + title: "Cambio de Contraseña Requerido", + description: + "Parece que tu contraseña ha caducado o necesita ser actualizada. Por favor, restablece tu contraseña para continuar.", + status: "info", + duration: 6000, + isClosable: true, + }); + setIsResetting(true); + } else if (response.status === true) { + const { name, token } = response; + const decodedToken = jwtDecode(token); + const authorities = decodedToken.authorities || ""; - if (authorities.includes("ROLE_TEACHER")) { - redirectPath = "/teacher-dashboard"; - } else if (authorities.includes("ROLE_STUDENT")) { - redirectPath = "/student-dashboard"; - } else if (authorities.includes("ROLE_PARENT")) { - redirectPath = "/parent-dashboard"; - } else if (authorities.includes("ROLE_ADMIN")) { - redirectPath = "/admin"; - } + sessionStorage.setItem("name", name); + sessionStorage.setItem("token", token); + + // Redirige a la ruta basada en el rol del usuario + let redirectPath = "/"; + if (authorities.includes("ROLE_TEACHER")) { + redirectPath = "/teacher-dashboard"; + } else if (authorities.includes("ROLE_STUDENT")) { + redirectPath = "/student-dashboard"; + } else if (authorities.includes("ROLE_PARENT")) { + redirectPath = "/parent-dashboard"; + } else if (authorities.includes("ROLE_ADMIN")) { + redirectPath = "/admin"; + } - navigate(redirectPath); + navigate(redirectPath); + } } catch (error) { console.error("Error logging in:", error); toast({ title: "Error al iniciar sesión", - description: "Las credenciales son incorrectas.", + description: + "Las credenciales son incorrectas o hubo un problema con el servidor.", status: "error", duration: 5000, isClosable: true, }); + } finally { + setIsLoading(false); } }; @@ -103,7 +96,7 @@ const Login = () => { setIsResetting(false); setResetEmail(""); // Limpiar campo de email } catch (error) { - console.error(error); + console.error("Error sending reset email:", error); toast({ title: "Error", description: "No se pudo enviar el correo de restablecimiento.", @@ -160,6 +153,7 @@ const Login = () => { borderColor: "#34495E", boxShadow: "0 0 15px rgba(52, 73, 94, 0.5)", }} + autoComplete="email" /> + + + + + {/* Modal de Rendimiento */} + + + - - Ver Calificaciones - - - Revisa tus calificaciones y el progreso académico. - - - - - + + {/* Contenido del modal de Rendimiento */} + + + + + + + + + {/* Modal de Mensajes */} + + + - - Perfil - - Edita tu perfil y configura tu cuenta. - - - - - + + Mensajes + + {/* Contenido del modal de Mensajes */} + + Aquí puedes revisar y enviar mensajes a estudiantes y otros + profesores. + + + + + + + + + + + ); }; -export default StudentDashboard; +export default TeacherDashboard; diff --git a/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx b/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx new file mode 100644 index 0000000..856181b --- /dev/null +++ b/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx @@ -0,0 +1,113 @@ +import { + Box, + Button, + Container, + Heading, + Table, + Thead, + Tbody, + Tr, + Th, + Td, + Text, + Flex, + useBreakpointValue, +} from "@chakra-ui/react"; + +const ViewEvaluations = () => { + // Datos de ejemplo, puedes reemplazar esto con tus datos reales + const studentInfo = { + name: "Yo soy", + lastName: "Groot", + dni: "0303456", + }; + + const evaluations = [ + { + year: "3º", + trimester: "Primero", + subject: "Matemáticas", + feedback: + "Buena comprensión, pero necesita practicar más ejercicios de la unidad 2.", + }, + { + year: "3º", + trimester: "Primero", + subject: "Lengua y Literatura", + feedback: "Excelente progreso, sigue practicando la lectura diaria.", + }, + { + year: "3º", + trimester: "Primero", + subject: "Historia", + feedback: + "Necesita mejorar la participación en clase y profundizar en las unidades 1, 2 y 3.", + }, + { + year: "3º", + trimester: "Primero", + subject: "Educación Física", + feedback: "Excelente rendimiento, continúa así!", + }, + ]; + + // Responsividad + const isMobile = useBreakpointValue({ base: true, md: false }); + + return ( + + + + Informe de Evaluaciones + + + {/* Información del Estudiante en una sola línea */} + + + Nombre: {studentInfo.name} + + + Apellido: {studentInfo.lastName} + + + DNI: {studentInfo.dni} + + + + {/* Tabla de Evaluaciones */} + + + + + + + + + + + {evaluations.map((evaluation, index) => ( + + + + + + + ))} + +
AñoTrimestreMateriaRetroalimentación
{evaluation.year}{evaluation.trimester}{evaluation.subject}{evaluation.feedback}
+
+
+ ); +}; + +export default ViewEvaluations; From f02b82ed8f7837d7a41b75b80ace30c9049e65be Mon Sep 17 00:00:00 2001 From: "Deyvi Correa Z." Date: Sat, 14 Sep 2024 09:32:56 -0300 Subject: [PATCH 2/3] --ValidateForms --- FrontEnd/react-app/package-lock.json | 5 -- .../react-app/src/pages/AdminDashboard.jsx | 1 - .../src/pages/admin/RegisterParent.jsx | 57 +++++++++++--- .../src/pages/admin/RegisterStudent.jsx | 76 ++++++++++++++----- .../src/pages/admin/RegisterTeacher.jsx | 14 ++++ 5 files changed, 119 insertions(+), 34 deletions(-) diff --git a/FrontEnd/react-app/package-lock.json b/FrontEnd/react-app/package-lock.json index 192c7c3..fc45b1b 100644 --- a/FrontEnd/react-app/package-lock.json +++ b/FrontEnd/react-app/package-lock.json @@ -910,7 +910,6 @@ "version": "2.8.2", "resolved": "https://registry.npmjs.org/@chakra-ui/react/-/react-2.8.2.tgz", "integrity": "sha512-Hn0moyxxyCDKuR9ywYpqgX8dvjqwu9ArwpIb9wHNYjnODETjLwazgNIliCVBRcJvysGRiV51U2/JtJVrpeCjUQ==", - "license": "MIT", "dependencies": { "@chakra-ui/accordion": "2.3.1", "@chakra-ui/alert": "2.2.2", @@ -1579,7 +1578,6 @@ "version": "11.13.3", "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.13.3.tgz", "integrity": "sha512-lIsdU6JNrmYfJ5EbUCf4xW1ovy5wKQ2CkPRM4xogziOxH1nXxBSjpC9YqbFAP7circxMfYp+6x676BqWcEiixg==", - "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.12.0", @@ -1620,7 +1618,6 @@ "version": "11.13.0", "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.13.0.tgz", "integrity": "sha512-tkzkY7nQhW/zC4hztlwucpT8QEZ6eUzpXDRhww/Eej4tFfO0FxQYWRyg/c5CCXa4d/f174kqeXYjuQRnhzf6dA==", - "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.12.0", @@ -3832,7 +3829,6 @@ "version": "11.5.4", "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.5.4.tgz", "integrity": "sha512-E+tb3/G6SO69POkdJT+3EpdMuhmtCh9EWuK4I1DnIC23L7tFPrl8vxP+LSovwaw6uUr73rUbpb4FgK011wbRJQ==", - "license": "MIT", "dependencies": { "tslib": "^2.4.0" }, @@ -5123,7 +5119,6 @@ "version": "7.53.0", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.53.0.tgz", "integrity": "sha512-M1n3HhqCww6S2hxLxciEXy2oISPnAzxY7gvwVPrtlczTM/1dDadXgUxDpHMrMTblDOcm/AXtXxHwZ3jpg1mqKQ==", - "license": "MIT", "engines": { "node": ">=18.0.0" }, diff --git a/FrontEnd/react-app/src/pages/AdminDashboard.jsx b/FrontEnd/react-app/src/pages/AdminDashboard.jsx index 25ed4e8..f2a7b4c 100644 --- a/FrontEnd/react-app/src/pages/AdminDashboard.jsx +++ b/FrontEnd/react-app/src/pages/AdminDashboard.jsx @@ -199,7 +199,6 @@ const AdminDashboard = () => { display="flex" flexDirection="column" > - Registrar Padre/Tutor diff --git a/FrontEnd/react-app/src/pages/admin/RegisterParent.jsx b/FrontEnd/react-app/src/pages/admin/RegisterParent.jsx index 926f481..9a7113b 100644 --- a/FrontEnd/react-app/src/pages/admin/RegisterParent.jsx +++ b/FrontEnd/react-app/src/pages/admin/RegisterParent.jsx @@ -43,6 +43,32 @@ const RegisterParent = () => { // Watch for changes in child IDs const children = watch("children"); + const handleDniChange = async (index, event) => { + const dni = event.target.value; + if (dni.length === 8) { + try { + const studentData = await verifyChildByDni(dni); + if (studentData) { + setValue( + `children.${index}.childName`, + `${studentData.firstName || ""} ${studentData.lastName || ""}` + ); + } + } catch (error) { + console.error(error); + toast({ + title: "Error", + description: "No se pudo obtener la información del estudiante.", + status: "error", + duration: 5000, + isClosable: true, + }); + } + } else { + setValue(`children.${index}.childName`, ""); + } + }; + useEffect(() => { const fetchStudentData = async () => { const childDNIs = children @@ -123,7 +149,7 @@ const RegisterParent = () => { console.error(error); toast({ title: "Error", - description: "No se pudo registrar al padre/madre.", + description: "No se pudo registrar al padre/tutor.", status: "error", duration: 55000, isClosable: true, @@ -140,7 +166,7 @@ const RegisterParent = () => { boxShadow="0 4px 8px rgba(0, 0, 0, 0.9)" > - Registro de Padre/Madre + Registro de Padre/Tutor
@@ -197,6 +223,10 @@ const RegisterParent = () => { placeholder="Ej: 35765489, 19432567" {...register("dni", { required: "Este campo es obligatorio", + pattern: { + value: /^[0-9]{8}$/, + message: "El DNI debe tener exactamente 8 dígitos", + }, })} /> {errors.dni && ( @@ -333,6 +363,16 @@ const RegisterParent = () => { placeholder="Ej: 1187693452, 113465879234" {...register("emergencyPhone", { required: "Este campo es obligatorio", + maxLength: { + value: 10, + message: + "El número de teléfono no puede tener más de 10 dígitos", + }, + pattern: { + value: /^[0-9]{10}$/, + message: + "El número de teléfono debe tener exactamente 10 dígitos", + }, })} /> {errors.emergencyPhone && ( @@ -455,7 +495,7 @@ const RegisterParent = () => { {/* Hijos */} - Hijos + Estudiante {fields.map((item, index) => ( @@ -470,7 +510,7 @@ const RegisterParent = () => { isRequired > - D.N.I. del Niño/a: + D.N.I.: { {...register(`children.${index}.childDNI`, { required: "Este campo es obligatorio", })} + onChange={(e) => handleDniChange(index, e)} /> {errors.children?.[index]?.childDNI && ( @@ -493,12 +534,12 @@ const RegisterParent = () => { isRequired > - Nombre del Niño/a: + Nombre/s: { ))} {/* Botón de Enviar */} diff --git a/FrontEnd/react-app/src/pages/admin/RegisterStudent.jsx b/FrontEnd/react-app/src/pages/admin/RegisterStudent.jsx index b45c8bf..30a4ab8 100644 --- a/FrontEnd/react-app/src/pages/admin/RegisterStudent.jsx +++ b/FrontEnd/react-app/src/pages/admin/RegisterStudent.jsx @@ -55,8 +55,9 @@ const RegisterStudent = () => { emergencyNumber: data.emergencyContactPhone, medicalInformation, session: data.session, - registrationNumber: data.registrationNumber, }; + // Muestra el Objeto que se envia + // console.log(data); const response = await registerStudent(finalData); const generatedPassword = response?.password || "123456"; // Reemplaza con lógica real si es necesario @@ -116,6 +117,10 @@ const RegisterStudent = () => { placeholder="Ej: Julio Armando" {...register("firstName", { required: "Este campo es obligatorio", + minLength: { + value: 2, + message: "El nombre debe tener al menos 2 caracteres", + }, })} /> {errors.firstName && ( @@ -132,6 +137,10 @@ const RegisterStudent = () => { placeholder="Ej: Salvador" {...register("lastName", { required: "Este campo es obligatorio", + minLength: { + value: 2, + message: "El apellido debe tener al menos 2 caracteres", + }, })} /> {errors.lastName && ( @@ -165,6 +174,10 @@ const RegisterStudent = () => { placeholder="Ej: 45872875" {...register("dni", { required: "Este campo es obligatorio", + pattern: { + value: /^[0-9]{8}$/, + message: "El DNI debe tener exactamente 8 dígitos", + }, })} /> {errors.dni && ( @@ -197,6 +210,16 @@ const RegisterStudent = () => { placeholder="Ej: 1154327854" {...register("phoneNumber", { required: "Este campo es obligatorio", + maxLength: { + value: 10, + message: + "El número de teléfono no puede tener más de 10 dígitos", + }, + pattern: { + value: /^[0-9]{10}$/, + message: + "El número de teléfono debe tener exactamente 10 dígitos", + }, })} /> {errors.phone && ( @@ -222,6 +245,10 @@ const RegisterStudent = () => { placeholder="Ej: Av. Corrientes 1234, Piso 2, Dpto A" {...register("addressStreet", { required: "Este campo es obligatorio", + minLength: { + value: 5, + message: "La calle debe tener al menos 5 caracteres", + }, })} /> {errors.addressStreet && ( @@ -238,6 +265,10 @@ const RegisterStudent = () => { placeholder="Ej: Ciudad Autónoma de Buenos Aires" {...register("addressCity", { required: "Este campo es obligatorio", + minLength: { + value: 3, + message: "La ciudad debe tener al menos 3 caracteres", + }, })} /> {errors.addressCity && ( @@ -254,6 +285,10 @@ const RegisterStudent = () => { placeholder="Ej: Buenos Aires" {...register("addressProvince", { required: "Este campo es obligatorio", + minLength: { + value: 3, + message: "La provincia debe tener al menos 3 caracteres", + }, })} /> {errors.addressProvince && ( @@ -270,6 +305,10 @@ const RegisterStudent = () => { placeholder="Ej: C1043AAE" {...register("addressZipcode", { required: "Este campo es obligatorio", + pattern: { + value: /^[A-Z0-9]{4,7}$/, + message: "El código postal no es válido", + }, })} /> {errors.addressZipcode && ( @@ -286,23 +325,7 @@ const RegisterStudent = () => { - - - - Número de Matrícula: - - - {errors.registrationNumber && ( - - {errors.registrationNumber.message} - - )} - - + Turno: @@ -341,6 +364,11 @@ const RegisterStudent = () => { placeholder="Ej: Juan Carlos Salvador" {...register("emergencyContactName", { required: "Este campo es obligatorio", + minLength: { + value: 3, + message: + "El nombre del contacto debe tener al menos 3 caracteres", + }, })} /> {errors.emergencyContactName && ( @@ -353,7 +381,7 @@ const RegisterStudent = () => { - Teléfono del Contacto: + Celular (emergencias): { placeholder="Ej: 1163238756" {...register("emergencyNumber", { required: "Este campo es obligatorio", + maxLength: { + value: 10, + message: + "El número de teléfono no puede tener más de 10 dígitos", + }, + pattern: { + value: /^[0-9]{10}$/, + message: + "El número de teléfono debe tener exactamente 10 dígitos", + }, })} /> {errors.emergencyContactPhone && ( diff --git a/FrontEnd/react-app/src/pages/admin/RegisterTeacher.jsx b/FrontEnd/react-app/src/pages/admin/RegisterTeacher.jsx index 3f4c35b..c16e5d5 100644 --- a/FrontEnd/react-app/src/pages/admin/RegisterTeacher.jsx +++ b/FrontEnd/react-app/src/pages/admin/RegisterTeacher.jsx @@ -186,6 +186,10 @@ const RegisterTeacher = () => { placeholder="Ej: 3387456, 2945687" {...register("dni", { required: "Este campo es obligatorio", + pattern: { + value: /^[0-9]{8}$/, + message: "El DNI debe tener exactamente 8 dígitos", + }, })} /> {errors.dni && ( @@ -497,6 +501,16 @@ const RegisterTeacher = () => { placeholder="Ej: 1187693452, 113465879234" {...register("emergencyNumber", { required: "Este campo es obligatorio", + maxLength: { + value: 10, + message: + "El número de teléfono no puede tener más de 10 dígitos", + }, + pattern: { + value: /^[0-9]{10}$/, + message: + "El número de teléfono debe tener exactamente 10 dígitos", + }, })} /> {errors.emergencyNumber && ( From 630cbec2eef701b58ab4f7ba262126cd77c9adad Mon Sep 17 00:00:00 2001 From: "Deyvi Correa Z." Date: Sun, 15 Sep 2024 12:45:39 -0300 Subject: [PATCH 3/3] --someUpdates --- .../react-app/src/pages/TeacherDashboard.jsx | 6 +- .../src/pages/student/ViewNotifications.jsx | 0 .../src/pages/student/viewEvaluations.jsx | 115 +++++----- .../src/pages/teacher/RegisterEvaluations.jsx | 30 ++- .../src/pages/teacher/SendNotifications.jsx | 202 ++++++++++++++++++ .../react-app/src/services/teacherService.js | 10 +- 6 files changed, 288 insertions(+), 75 deletions(-) create mode 100644 FrontEnd/react-app/src/pages/student/ViewNotifications.jsx create mode 100644 FrontEnd/react-app/src/pages/teacher/SendNotifications.jsx diff --git a/FrontEnd/react-app/src/pages/TeacherDashboard.jsx b/FrontEnd/react-app/src/pages/TeacherDashboard.jsx index 485f1d9..b97ab73 100644 --- a/FrontEnd/react-app/src/pages/TeacherDashboard.jsx +++ b/FrontEnd/react-app/src/pages/TeacherDashboard.jsx @@ -25,6 +25,7 @@ import btnRendimiento from "../assets/tu_rendimiento.webp"; import btnMensajes from "../assets/tus_mensajes.webp"; import "./Dashboard.css"; import RegisterEvaluations from "./teacher/RegisterEvaluations"; +import SendNotifications from "./teacher/sendNotifications"; const TeacherDashboard = () => { const [name, setName] = useState(""); @@ -191,10 +192,7 @@ const TeacherDashboard = () => { Mensajes {/* Contenido del modal de Mensajes */} - - Aquí puedes revisar y enviar mensajes a estudiantes y otros - profesores. - + {/* Aquí puedes incluir el componente o el contenido específico */} diff --git a/FrontEnd/react-app/src/pages/student/ViewNotifications.jsx b/FrontEnd/react-app/src/pages/student/ViewNotifications.jsx new file mode 100644 index 0000000..e69de29 diff --git a/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx b/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx index 856181b..ae6e749 100644 --- a/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx +++ b/FrontEnd/react-app/src/pages/student/viewEvaluations.jsx @@ -1,6 +1,7 @@ +import React, { useEffect, useState } from "react"; +import { getEvaluationsByDni } from "../../services/teacherService"; // Asegúrate de que esta ruta sea correcta import { Box, - Button, Container, Heading, Table, @@ -15,45 +16,35 @@ import { } from "@chakra-ui/react"; const ViewEvaluations = () => { - // Datos de ejemplo, puedes reemplazar esto con tus datos reales const studentInfo = { name: "Yo soy", lastName: "Groot", - dni: "0303456", + dni: "12222222", }; - const evaluations = [ - { - year: "3º", - trimester: "Primero", - subject: "Matemáticas", - feedback: - "Buena comprensión, pero necesita practicar más ejercicios de la unidad 2.", - }, - { - year: "3º", - trimester: "Primero", - subject: "Lengua y Literatura", - feedback: "Excelente progreso, sigue practicando la lectura diaria.", - }, - { - year: "3º", - trimester: "Primero", - subject: "Historia", - feedback: - "Necesita mejorar la participación en clase y profundizar en las unidades 1, 2 y 3.", - }, - { - year: "3º", - trimester: "Primero", - subject: "Educación Física", - feedback: "Excelente rendimiento, continúa así!", - }, - ]; + const [evaluations, setEvaluations] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); - // Responsividad const isMobile = useBreakpointValue({ base: true, md: false }); + useEffect(() => { + const fetchEvaluations = async () => { + try { + const data = await getEvaluationsByDni(studentInfo.dni); + console.log("Data received:", data); // Verifica los datos recibidos + setEvaluations(data); + } catch (error) { + console.error("Error fetching evaluations:", error); // Manejo de errores detallado + setError(error.message || "Error al obtener las evaluaciones"); + } finally { + setLoading(false); + } + }; + + fetchEvaluations(); + }, [studentInfo.dni]); + return ( @@ -61,7 +52,6 @@ const ViewEvaluations = () => { Informe de Evaluaciones - {/* Información del Estudiante en una sola línea */} { - {/* Tabla de Evaluaciones */} - - - - - - - - - - - {evaluations.map((evaluation, index) => ( - - - - - + {loading && Cargando evaluaciones...} + {error && ( + + {error} + + )} + + {!loading && !error && evaluations.length > 0 && ( +
AñoTrimestreMateriaRetroalimentación
{evaluation.year}{evaluation.trimester}{evaluation.subject}{evaluation.feedback}
+ + + + + + - ))} - -
AñoTrimestreMateriaRetroalimentación
+ + + {evaluations.map((evaluation, index) => ( + + {evaluation.year} + {evaluation.trimester} + {evaluation.subject} + {evaluation.feedback} + + ))} + + + )} + {!loading && !error && evaluations.length === 0 && ( + No hay evaluaciones para mostrar. + )}
); diff --git a/FrontEnd/react-app/src/pages/teacher/RegisterEvaluations.jsx b/FrontEnd/react-app/src/pages/teacher/RegisterEvaluations.jsx index cc101d8..0322dc5 100644 --- a/FrontEnd/react-app/src/pages/teacher/RegisterEvaluations.jsx +++ b/FrontEnd/react-app/src/pages/teacher/RegisterEvaluations.jsx @@ -9,11 +9,11 @@ import { Input, Select, Textarea, - useToast + useToast, } from "@chakra-ui/react"; import { useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; -import { verifyChildByDni } from "../../services/adminService"; // Asegúrate de que la ruta sea correcta +import { verifyChildByDni } from "../../services/adminService"; import { loadEvaluation } from "../../services/teacherService"; const RegisterEvaluations = () => { @@ -89,7 +89,7 @@ const RegisterEvaluations = () => { evaluations, }; - const response = await loadEvaluation(finalData); + const response = await loadEvaluation(finalData); // Utiliza el endpoint adecuado setConfirmationMessage( `Evaluaciones registradas con éxito. ${response.message || ""}` @@ -132,7 +132,9 @@ const RegisterEvaluations = () => { {/* Información del Estudiante */} - DNI del alumno: + + DNI del alumno: + { - Nombre del alumno: + + Nombre del alumno: + { - Año: + + Año: + @@ -198,7 +206,9 @@ const RegisterEvaluations = () => { - Materia: + + Materia: + { - Retroalimentación: + + Retroalimentación: +