71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
import React, {Component} from "react";
|
|
import '../Style.css'
|
|
|
|
class Absences extends Component {
|
|
constructor(props){
|
|
super(props)
|
|
this.state = {
|
|
abs: []
|
|
}
|
|
}
|
|
|
|
componentDidUpdate(prevProps) {
|
|
if (prevProps.id !== this.props.id) {
|
|
this.getData();
|
|
}
|
|
}
|
|
|
|
componentDidMount() {
|
|
if (this.props.id !== "") {this.getData()}
|
|
}
|
|
|
|
getData() {
|
|
let dept = window.location.href.split('/')[6]
|
|
let BASE_URL = window.$api_url
|
|
if (this.state.id !== "") {
|
|
fetch(BASE_URL + dept + "/Scolarite/Absences/ListeAbsEtud?format=json&etudid=" + this.props.id, {
|
|
method: 'GET',
|
|
verify: false,
|
|
credentials: 'include',
|
|
})
|
|
.then(response =>
|
|
response.json().then(data => ({
|
|
data: data,
|
|
})
|
|
).then(res => {
|
|
this.setState({abs: res.data})
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="wrapper">
|
|
<h1 id="pageTitle">Gestion des absences</h1>
|
|
{this.props.name !== "" &&
|
|
<div className="col-sm" id="wrapDept">
|
|
<h4>Absences de {this.props.name}</h4>
|
|
{(this.state.abs.length === 0 && this.props.name !== "") &&
|
|
<h6>Aucune absence de l'élève</h6>
|
|
}
|
|
{this.state.abs.map((abs, index) => {
|
|
return (
|
|
<div className="col-sm" id="wrapDept">
|
|
<h6>{abs.datedmy} | {abs.matin}</h6>
|
|
{abs.motif !== "" &&
|
|
<span>Motif: {abs.motif}</span>
|
|
} {abs.exams !== "" &&
|
|
<span>Exam a rattraper: {abs.exams}</span>
|
|
}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default Absences |