ScoDocMobile/src/ScoDoc/Scolarite.js

116 lines
4.9 KiB
JavaScript
Raw Normal View History

2021-04-29 14:18:26 +02:00
import React, {Component} from "react";
import {Link} from "react-router-dom";
2021-04-29 14:18:26 +02:00
import './Style.css'
import ScoNavBar from "./ScoNavBar";
import SearchStudent from './SearchStudent'
import {Accordion, Card, Button} from 'react-bootstrap'
import {getJson} from "./Request";
2021-04-29 14:18:26 +02:00
/** Page de choix du semestre */
2021-04-29 14:18:26 +02:00
class Scolarite extends Component {
constructor(props) {
super(props);
this.state = {
semestres: [],
students: [],
toast: false
};
this.dismissToast = this.dismissToast.bind(this);
}
componentWillMount() {
this.getData()
2021-04-29 14:18:26 +02:00
}
/**
* Recupère la liste des semestres depuis l'API
*/
2021-04-29 14:18:26 +02:00
getData () {
let dept = window.location.href.split('/')[7]
let BASE_URL = window.$api_url
getJson(BASE_URL + dept + '/Scolarite/Notes/formsemestre_list?format=json')
.then(res => {
this.setState({ semestres: res.data });
})
2021-04-29 14:18:26 +02:00
}
dismissToast = () => this.setState({toast: false})
2021-04-29 14:18:26 +02:00
render() {
return (
<div>
<ScoNavBar/>
<section>
<h1 id="pageTitle">Scolarité</h1>
</section>
<Accordion defaultActiveKey="0">
<Card>
<Card.Header>
<Accordion.Toggle as={Button} variant="link" eventKey="0">
2021-05-10 17:27:18 +02:00
Semestres en cours
2021-04-29 14:18:26 +02:00
</Accordion.Toggle>
</Card.Header>
<Accordion.Collapse eventKey="0">
<Card.Body>
<div className="container">
<div className="row">
{this.state.semestres.map((sem, index) => {
if (sem.etat === "1") {
return (
<div className="col-sm" key={index} id="wrapDept">
<Link to={`/${window.location.href.split('/')[7]}/Scolarite/${sem.formsemestre_id}/GestionSem`}>
<h4>{sem.titre} [{sem.modalite}]</h4>
<p>Semestre {sem.semestre_id} - Année {sem.anneescolaire} [{sem.date_debut} - {sem.date_fin}]</p>
</Link>
</div>
)
}
})}
</div>
</div>
2021-04-29 14:18:26 +02:00
</Card.Body>
</Accordion.Collapse>
</Card>
<Card>
<Card.Header>
<Accordion.Toggle as={Button} variant="link" eventKey="1">
2021-05-10 17:27:18 +02:00
Semestres passés
2021-04-29 14:18:26 +02:00
</Accordion.Toggle>
</Card.Header>
<Accordion.Collapse eventKey="1">
2021-05-10 17:27:18 +02:00
<Card.Body>
{this.state.semestres.map((sem, index) => {
if (sem.etat !== "1") {
2021-05-10 17:27:18 +02:00
return (
<div className="col-12" key={index} id="wrapDept">
<Link to={`/${window.location.href.split('/')[7]}/Scolarite/${sem.formsemestre_id}/GestionSem`}>
2021-05-10 17:27:18 +02:00
<h3>{sem.titre} [{sem.modalite}]</h3>
<p>Semestre {sem.semestre_id} - Année {sem.anneescolaire} [{sem.date_debut} - {sem.date_fin}]</p>
</Link>
</div>
)
}
2021-05-10 17:27:18 +02:00
})}
</Card.Body>
</Accordion.Collapse>
</Card>
<Card>
<Card.Header>
<Accordion.Toggle as={Button} variant="link" eventKey="2">
Recherche étudiant
</Accordion.Toggle>
</Card.Header>
<Accordion.Collapse eventKey="2">
2021-04-29 14:18:26 +02:00
<Card.Body>
<SearchStudent />
2021-04-29 14:18:26 +02:00
</Card.Body>
</Accordion.Collapse>
</Card>
</Accordion>
</div>
);
2021-04-29 14:18:26 +02:00
}
}
export default Scolarite;