Skip to content

Commit ffa0066

Browse files
authored
Merge pull request #158 from TeraBlitz/FindPeriodoApi
Find periodo api + AlumnosFix
2 parents ac5f038 + 32553ee commit ffa0066

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

FrontEnd/src/Pages/ControlPanel/PagesCP/Alumnos/Alumnos.jsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { CSVLink } from "react-csv";
1818

1919
import Select from "react-select";
2020
import { deleteStudent, getStudents, updateStudent } from "../../../../api/students";
21-
import { getPeriodos } from "../../../../api/Periodos";
21+
import { findPeriodos, getPeriodos } from "../../../../api/Periodos";
2222
import { getClassStudent } from "../../../../api/classStudent";
2323

2424
export default function Alumnos() {
@@ -37,27 +37,31 @@ export default function Alumnos() {
3737

3838
const getAlumnos = async () => {
3939
await getStudents().then(response => response.json()).then(result => {
40+
console.log(result)
4041
setData(result);
4142
})
4243

4344
};
4445

4546
const getAlumnos2 = async () => {
4647
await getStudents().then(response => response.json()).then(result => {
48+
console.log(result)
4749
setGuardaData(result);
4850
})
4951

5052
};
5153

5254
const getAllPeriodos = async () => {
5355
await getPeriodos().then(response => response.json()).then(result => {
56+
console.log(result)
5457
setDataPeriodo(result);
5558
})
5659

5760
};
5861

5962
const getAlumnoClase = async () => {
6063
await getClassStudent().then(response => response.json()).then(result => {
64+
console.log(result)
6165
setDataAlumnoClase(result);
6266
})
6367
};
@@ -183,8 +187,8 @@ export default function Alumnos() {
183187
const postDelete = async (e) => {
184188
try {
185189
await deleteStudent({
186-
_id: consolaSeleccionada._id,
187-
})
190+
_id: consolaSeleccionada._id,
191+
})
188192
abrirCerrarModalEliminar();
189193
getAlumnos();
190194
} catch (error) {
@@ -842,26 +846,26 @@ export default function Alumnos() {
842846
[data]
843847
);
844848

845-
const handleSelectChange = (event) => {
849+
const handleSelectChange = async (event) => {
846850

847851
array = []
848852
array2 = []
849853
array3 = []
850-
console.log(guardaData)
851-
console.log(event.value);
852-
854+
let arrayrepeated = []
853855
array2.push(dataAlumnoClase.filter(data => data.idPeriodo === event.value));
856+
array2 = array2.filter(data => data != undefined)
854857
console.log(array2[0])
855858
for (let i = 0; i < array2.length; i++) {
856859
for (let j = 0; j < array2[i].length; j++) {
857-
array.push(guardaData.filter(data => data._id === array2[i][j].idAlumno))
860+
array.push(guardaData.filter(data => data._id === array2[i][j].idAlumno && !arrayrepeated.includes(array2[i][j].idAlumno)))
861+
arrayrepeated.push(array2[i][j].idAlumno)
858862
}
859863
}
860-
console.log(array)
864+
array = array.filter(data => data != [])
861865
for (let i = 0; i < array.length; i++) {
862-
array3.push(array[i][0])
866+
array3.push(array[i][0])
863867
}
864-
console.log(array3)
868+
array3 = array3.filter(data => data != undefined)
865869
if (array3.length > 0) {
866870
setData(array3)
867871
} else {

FrontEnd/src/api/Periodos.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ export const getPeriodos = () => {
1515
export const deletePeriodos = (periodo) => {
1616
return deleteData(`/v1/periodos/delete`, periodo)
1717
}
18+
export const findPeriodos = (idPeriodo) =>{
19+
return postData("/v1/periodos/find" , idPeriodo)
20+
}

backend/v1/routes/periodos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ router.post('/find', periodoController.findPeriodo)
1212
router.put('/update', validatePeriodo.validatePeriodo, periodoController.updatePeriodo)
1313
router.delete('/delete', periodoController.deletePeriodo)
1414

15-
module.exports = router
15+
module.exports = router

0 commit comments

Comments
 (0)