@@ -18,7 +18,7 @@ import { CSVLink } from "react-csv";
1818
1919import Select from "react-select" ;
2020import { deleteStudent , getStudents , updateStudent } from "../../../../api/students" ;
21- import { getPeriodos } from "../../../../api/Periodos" ;
21+ import { findPeriodos , getPeriodos } from "../../../../api/Periodos" ;
2222import { getClassStudent } from "../../../../api/classStudent" ;
2323
2424export 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 {
0 commit comments