Skip to content

Commit 159a2d2

Browse files
authored
Merge pull request #51 from No-Country-simulation/deyvicz
--someUpdates
2 parents 20f8709 + afa62e9 commit 159a2d2

13 files changed

+202
-95
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
7.42 KB
Binary file not shown.

FrontEnd/react-app/src/pages/StudentDashboard.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import logo from "../assets/logoDonorinoSchoolBlack.webp";
2222
import btnHistorial from "../assets/tu_historial_academico.webp";
2323
import btnRendimiento from "../assets/tu_rendimiento.webp";
2424
import btnMensajes from "../assets/tus_mensajes.webp";
25-
import ViewEvaluations from "./student/ViewEvaluations";
2625
import ViewNotifications from "./student/ViewNotifications";
2726
import "./Dashboard.css";
2827
import AcademicRecord from "./student/ViewAcademicRecord";
28+
import ViewEvaluationsByStudent from "./student/ViewEvaluationsByStudent";
2929

3030
const TeacherDashboard = () => {
3131
const [name, setName] = useState("");
@@ -164,7 +164,7 @@ const TeacherDashboard = () => {
164164
<ModalCloseButton />
165165
<ModalBody overflowY="auto">
166166
{/* Contenido del modal de Rendimiento */}
167-
<ViewEvaluations />
167+
<ViewEvaluationsByStudent />
168168
</ModalBody>
169169
<ModalFooter>
170170
<Button colorScheme="orange" onClick={onRendimientoClose}>

FrontEnd/react-app/src/pages/TeacherDashboard.jsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ import {
2020
import React, { useState, useEffect } from "react";
2121
import { useNavigate } from "react-router-dom";
2222
import logo from "../assets/logoDonorinoSchoolBlack.webp";
23-
import btnHistorial from "../assets/tu_historial_academico.webp";
24-
import btnRendimiento from "../assets/tu_rendimiento.webp";
25-
import btnMensajes from "../assets/tus_mensajes.webp";
23+
import btnHistorial from "../assets/historial_academico.webp";
24+
import btnRendimiento from "../assets/rendimiento.webp";
25+
import btnEnviar from "../assets/enviar_notificaciones.webp";
26+
import btnRecibir from "../assets/recibir_notificaciones.webp";
2627
import "./Dashboard.css";
27-
import RegisterEvaluations from "./teacher/RegisterEvaluations";
28-
import SendNotifications from "./teacher/sendNotifications";
2928
import AcademicRecord from "./teacher/AcademicRecord";
29+
import RegisterEvaluations from "./teacher/RegisterEvaluations";
30+
import SendNotifications from "./teacher/SendNotifications";
3031

3132
const TeacherDashboard = () => {
3233
const [name, setName] = useState("");
@@ -110,8 +111,16 @@ const TeacherDashboard = () => {
110111
</a>
111112
<a href="#" onClick={onMensajesOpen}>
112113
<Image
113-
src={btnMensajes}
114-
alt="Mensajes y Notificaciones"
114+
src={btnEnviar}
115+
alt="Enviar Notificaciones"
116+
className="option-img"
117+
/>
118+
</a>
119+
{/* Agregar evento OnClick */}
120+
<a href="#">
121+
<Image
122+
src={btnRecibir}
123+
alt="Recibir Notificaciones"
115124
className="option-img"
116125
/>
117126
</a>

FrontEnd/react-app/src/pages/parent/ViewAcademicRecord.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
Flex,
1414
useBreakpointValue,
1515
} from "@chakra-ui/react";
16-
import { verifyChildByDni } from "../../services/adminService";
16+
import { verifyStudentByParentDni } from "../../services/teacherService"; // Importa el nuevo servicio
1717

1818
const AcademicRecord = () => {
1919
const [studentInfo, setStudentInfo] = useState({
@@ -55,17 +55,17 @@ const AcademicRecord = () => {
5555
useEffect(() => {
5656
const dni = sessionStorage.getItem("dni");
5757
if (dni) {
58-
verifyChildByDni(dni)
58+
verifyStudentByParentDni(dni) // Usa el nuevo servicio
5959
.then((data) => {
6060
// Suponiendo que la respuesta contiene firstName y lastName
6161
setStudentInfo({
6262
firstName: data.firstName || "No disponible",
6363
lastName: data.lastName || "No disponible",
64-
dni: dni,
64+
dniStudent: data.dni,
6565
});
6666
})
6767
.catch((err) => {
68-
console.error("Error al verificar el DNI:", err);
68+
console.error("Error al verificar el estudiante:", err);
6969
});
7070
}
7171
}, []);
@@ -79,7 +79,7 @@ const AcademicRecord = () => {
7979
boxShadow="0 4px 8px rgba(0, 0, 0, 0.9)"
8080
>
8181
<Heading as="h1" mb={6} textAlign="center" color="orange.500">
82-
Historial Academico
82+
Historial Académico
8383
</Heading>
8484

8585
<Box mb={6} p={4} borderWidth={1} borderRadius="md">
@@ -91,7 +91,7 @@ const AcademicRecord = () => {
9191
<strong>Apellido:</strong> {studentInfo.lastName}
9292
</Text>
9393
<Text>
94-
<strong>DNI:</strong> {studentInfo.dni}
94+
<strong>DNI:</strong> {studentInfo.dniStudent}
9595
</Text>
9696
</Flex>
9797
</Box>

FrontEnd/react-app/src/pages/parent/ViewEvaluations.jsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Flex,
1515
useBreakpointValue,
1616
} from "@chakra-ui/react";
17-
import { verifyChildByDni } from "../../services/adminService";
17+
import { verifyStudentByParentDni } from "../../services/teacherService"; // Asegúrate de que la ruta sea correcta
1818

1919
const ViewEvaluations = () => {
2020
const [evaluations, setEvaluations] = useState([]);
@@ -23,23 +23,26 @@ const ViewEvaluations = () => {
2323
const [studentInfo, setStudentInfo] = useState({
2424
firstName: "",
2525
lastName: "",
26-
dni: "",
26+
studentDni: "", // Cambiado el nombre de dni a studentDni
2727
});
2828

2929
const isMobile = useBreakpointValue({ base: true, md: false });
3030

3131
useEffect(() => {
32-
const dni = sessionStorage.getItem("dni");
32+
const dniParent = sessionStorage.getItem("dni"); // Cambiado a dniParent
3333

34-
if (dni) {
35-
verifyChildByDni(dni)
34+
if (dniParent) {
35+
// Verificando dniParent
36+
verifyStudentByParentDni(dniParent) // Usando dniParent aquí
3637
.then((data) => {
38+
console.log("Datos del estudiante:", data); // Consola para verificar los datos
3739
setStudentInfo({
3840
firstName: data.firstName || "No disponible",
3941
lastName: data.lastName || "No disponible",
40-
dni: dni,
42+
studentDni: data.dni || "No disponible", // Suponiendo que el DNI del estudiante está aquí
4143
});
42-
fetchEvaluations(dni);
44+
// Aquí usamos el DNI del estudiante
45+
fetchEvaluations(data.dni); // Usando el DNI del estudiante
4346
})
4447
.catch((err) => {
4548
console.error("Error al verificar el DNI:", err);
@@ -52,10 +55,11 @@ const ViewEvaluations = () => {
5255
}
5356
}, []);
5457

55-
const fetchEvaluations = async (dni) => {
58+
const fetchEvaluations = async (studentDni) => {
59+
// Cambiado a studentDni
5660
setLoading(true);
5761
try {
58-
const data = await getEvaluationsByDni(dni);
62+
const data = await getEvaluationsByDni(studentDni); // Usando studentDni aquí
5963
console.log("Data received:", data);
6064
setEvaluations(data);
6165
} catch (error) {
@@ -87,7 +91,8 @@ const ViewEvaluations = () => {
8791
<strong>Apellido:</strong> {studentInfo.lastName}
8892
</Text>
8993
<Text>
90-
<strong>DNI:</strong> {studentInfo.dni}
94+
<strong>DNI:</strong> {studentInfo.studentDni}{" "}
95+
{/* Usando el nuevo nombre */}
9196
</Text>
9297
</Flex>
9398
</Box>

FrontEnd/react-app/src/pages/student/viewEvaluations.jsx renamed to FrontEnd/react-app/src/pages/student/ViewEvaluationsByStudent.jsx

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import {
1616
} from "@chakra-ui/react";
1717
import { verifyChildByDni } from "../../services/adminService";
1818

19-
const ViewEvaluations = () => {
20-
const [evaluations, setEvaluations] = useState([]);
21-
const [loading, setLoading] = useState(true);
22-
const [error, setError] = useState(null);
19+
const ViewEvaluationsByStudent = () => {
20+
const [state, setState] = useState({
21+
evaluations: [],
22+
loading: true,
23+
error: null,
24+
});
2325
const [studentInfo, setStudentInfo] = useState({
2426
firstName: "",
2527
lastName: "",
@@ -43,26 +45,33 @@ const ViewEvaluations = () => {
4345
})
4446
.catch((err) => {
4547
console.error("Error al verificar el DNI:", err);
46-
setError("Error al verificar el DNI.");
47-
setLoading(false);
48+
setState({
49+
evaluations: [],
50+
loading: false,
51+
error: "Error al verificar el DNI.",
52+
});
4853
});
4954
} else {
50-
setError("DNI no encontrado en sessionStorage.");
51-
setLoading(false);
55+
setState({
56+
evaluations: [],
57+
loading: false,
58+
error: "DNI no encontrado en sessionStorage.",
59+
});
5260
}
5361
}, []);
5462

5563
const fetchEvaluations = async (dni) => {
56-
setLoading(true);
64+
setState((prevState) => ({ ...prevState, loading: true }));
5765
try {
5866
const data = await getEvaluationsByDni(dni);
59-
console.log("Data received:", data);
60-
setEvaluations(data);
67+
setState({ evaluations: data, loading: false, error: null });
6168
} catch (error) {
6269
console.error("Error fetching evaluations:", error);
63-
setError(error.message || "Error al obtener las evaluaciones");
64-
} finally {
65-
setLoading(false);
70+
setState({
71+
evaluations: [],
72+
loading: false,
73+
error: error.message || "Error al obtener las evaluaciones",
74+
});
6675
}
6776
};
6877

@@ -92,14 +101,16 @@ const ViewEvaluations = () => {
92101
</Flex>
93102
</Box>
94103

95-
{loading && <Text textAlign="center">Cargando evaluaciones...</Text>}
96-
{error && (
104+
{state.loading && (
105+
<Text textAlign="center">Cargando evaluaciones...</Text>
106+
)}
107+
{state.error && (
97108
<Text color="red.500" textAlign="center">
98-
{error}
109+
{state.error}
99110
</Text>
100111
)}
101112

102-
{!loading && !error && evaluations.length > 0 && (
113+
{!state.loading && !state.error && state.evaluations.length > 0 && (
103114
<Table
104115
variant="simple"
105116
size={isMobile ? "sm" : "md"}
@@ -110,15 +121,17 @@ const ViewEvaluations = () => {
110121
>
111122
<Thead bg="orange.400">
112123
<Tr>
113-
<Th>Año</Th>
114-
<Th>Trimestre</Th>
115-
<Th>Materia</Th>
116-
<Th>Retroalimentación</Th>
124+
<Th colorScheme="whiteAlpha">Año</Th>
125+
<Th colorScheme="whiteAlpha">Trimestre</Th>
126+
<Th colorScheme="whiteAlpha">Materia</Th>
127+
<Th colorScheme="whiteAlpha">Retroalimentación</Th>
117128
</Tr>
118129
</Thead>
119130
<Tbody bg="white">
120-
{evaluations.map((evaluation, index) => (
121-
<Tr key={index}>
131+
{state.evaluations.map((evaluation) => (
132+
<Tr key={evaluation.id}>
133+
{" "}
134+
{/* Cambia 'evaluation.id' por el campo único real */}
122135
<Td>{evaluation.year}</Td>
123136
<Td>{evaluation.trimester}</Td>
124137
<Td>{evaluation.subject}</Td>
@@ -128,12 +141,12 @@ const ViewEvaluations = () => {
128141
</Tbody>
129142
</Table>
130143
)}
131-
{!loading && !error && evaluations.length === 0 && (
144+
{!state.loading && !state.error && state.evaluations.length === 0 && (
132145
<Text textAlign="center">No hay evaluaciones para mostrar.</Text>
133146
)}
134147
</Box>
135148
</Container>
136149
);
137150
};
138151

139-
export default ViewEvaluations;
152+
export default ViewEvaluationsByStudent;

0 commit comments

Comments
 (0)