import React, {Component} from "react"; import {LazyLoadImage} from 'react-lazy-load-image-component'; import '../Style.css' import {Link} from "react-router-dom"; import {getJson} from "../Request"; import {Spinner} from "react-bootstrap"; /** Page de présentation des étudiants inscrits au semestre */ class Etudiants extends Component { constructor(props) { super(props); this.state = { // Liste des étudiants inscrits au semestre students: [], }; } componentWillMount() { // this.getData() } componentDidUpdate(prevProps) { if (prevProps !== this.props) { if (this.props.students.length) { const dat = this.props.students.map((x,i) => { return i % 2 === 0 ? this.props.students.slice(i, i+2) : null; }).filter(x => x != null); this.setState({ students: dat}); } } } /** * Recupère la liste des étudiants inscrits au semestre depuis l'API */ getData() { let dept = window.location.href.split('/')[7] let sem = window.location.href.split('/')[9] let BASE_URL = window.$api_url getJson(BASE_URL + dept + '/Scolarite/Notes/groups_view?with_codes=1&format=json&formsemestre_id=' + sem) .then(res => { // Gestion des données sous forme de tableau a deux colonnes const dat = res.data.map((x,i) => { return i % 2 === 0 ? res.data.slice(i, i+2) : null; }).filter(x => x != null); this.setState({ students: dat}); }) } render() { return (

Liste des étudiants

{this.state.students.length !== 0 ? this.state.students.map((students) => { // Creation du tableau de deux colonnes return (
{students.map((etud, index) => { return (
{/* Recuperation de la photo de l'etudiant */} {' '}
{etud.nom_disp} {etud.prenom}
) })}
) }) :
}
) } } export default Etudiants