import React, {Component} from "react"; import './Style.css' import ScoNavBar from "./ScoNavBar"; import {getJson} from "./Request"; /** Page d'information d'un étudiant' */ class Etudiant extends Component { constructor(props) { super(props); this.state = { // Données de l'étudiant etud: {}, // Formation actuelle de l'étudiant formation: [], // Semestres correspondant a la formation de l'étudiant semestres: [], loaded: false }; } componentWillMount() { this.getData() } /** * Recupère les données de l'étudiant depuis l'API */ getData() { let dept = window.location.href.split('/')[7] let etudid = window.location.href.split('/')[10] let BASE_URL = window.$api_url getJson(BASE_URL + dept + '/Scolarite/Notes/etud_info?format=json&etudid=' + etudid) .then(res => { this.setState({ etud: res.data, formation: res.data.insemestre }) // Recuperation des données de semestres pour la formation d'un étudiant res.data.insemestre.map((sem) => { getJson(BASE_URL + dept + '/Scolarite/Notes/formsemestre_list?format=json&formsemestre_id=' + sem.formsemestre_id) .then(res => { let joined = this.state.semestres.concat(res.data[0]); this.setState({ semestres: joined, loaded: true }) }) }) }) } render() { return(

{this.state.etud.nomprenom}

{`${this.state.etud.nomprenom}`}{' '}

Informations personnelles

{this.state.etud.telephone !== "" || this.state.etud.telephonemobile !== "" || this.state.etud.email !== "" || this.state.etud.emailperso !== "" ?

Contact

{this.state.etud.telephone !== "" && Téléphone: {this.state.etud.telephone}}
{this.state.etud.telephonemobile !== "" && Mobile: {this.state.etud.telephonemobile}}
{this.state.etud.email !== "" && Mail étudiant: {this.state.etud.email}}
{this.state.etud.emailperso !== "" && Mail personnel: {this.state.etud.emailperso}}
:
Aucun contact disponible
} {this.state.etud.domicile !== "" || this.state.etud.codepostaldomicile !== "" || this.state.etud.villedomicile !== "" ?

Lieu de résidence

Domicile: {this.state.etud.domicile} - {" " + this.state.etud.codepostaldomicile} {this.state.etud.villedomicile}
:
Aucune information de résidence disponible
}
{this.state.etud.bac !== "" || this.state.etud.specialite !== "" ?

Parcours

Bac {this.state.etud.bac} {this.state.etud.specialite} {this.state.etud.nomlycee !== "" || this.state.etud.codepostallycee !== "" || this.state.etud.villelycee !== "" ?
{" " + this.state.etud.nomlycee} ({this.state.etud.codepostallycee} {this.state.etud.villelycee})
: null}
: null} {this.state.loaded === true &&

Formation actuelle

{this.state.semestres.map((sem) => { return (
{sem.titreannee}
{sem.date_debut} - {sem.date_fin}
) })}
}
) } } export default Etudiant