import React, {Component} from "react"; import './Style.css' import ScoNavBar from "./ScoNavBar"; 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() { let dept = window.location.href.split('/')[6] let etudid = window.location.href.split('/')[9] let BASE_URL = window.$api_url fetch(BASE_URL + dept + '/Scolarite/Notes/etud_info?format=json&etudid=' + etudid, { method: 'GET', verify: false, credentials: 'include', }) .then(response => // Traitement des données JSON response.json().then(data => ({ data: data, status: response.status }) ).then(res => { this.setState({ etud: res.data }) this.setState({ formation: res.data.insemestre }) // Recuperation des données de semestres pour la formation d'un étudiant res.data.insemestre.map((sem, index) => { fetch(BASE_URL + dept + '/Scolarite/Notes/formsemestre_list?format=json&formsemestre_id=' + sem.formsemestre_id, { method: 'GET', verify: false, credentials: 'include', }) .then(response => response.json().then(data => ({ // Traitement des données JSON data: data, status: response.status })) ).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, index) => { return (
{sem.titreannee}
{sem.date_debut} - {sem.date_fin}
) })}
}
{/* TODO: Lien vers la gestion des absences
Gestion des absences
*/}
) } } export default Etudiant