ScoDocMobile/src/ScoDoc/ChoixDept.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-04-29 14:18:26 +02:00
import React, {Component} from "react";
2021-05-11 17:46:17 +02:00
import {Link} from "react-router-dom";
2021-04-29 14:18:26 +02:00
import './Style.css'
import {getJson} from './Request'
2021-04-29 14:18:26 +02:00
/** Page de choix du département */
2021-04-29 14:18:26 +02:00
class ChoixDept extends Component {
constructor(props) {
super(props);
this.state = {
// Liste des départements disponibles pour l'utilisateur
depts: [],
};
}
componentWillMount() {
this.getData()
}
/**
* Recupère la liste des départements depuis l'API
*/
getData() {
let BASE_URL = window.$api_url
getJson(BASE_URL + 'list_depts?format=json')
.then(res => {
this.setState({ depts: res.data })
});
}
2021-04-29 14:18:26 +02:00
render() {
return (
<div className="wrapper">
2021-05-11 17:46:17 +02:00
<h1 id="pageTitle">Choix du département</h1>
<div className="container">
<div className="row">
{this.state.depts.map((dept, index) => {
return (
<div className="col-sm" key={index} id="wrapDept">
<Link to={`/${dept}/Scolarite`}>
Département {dept}
</Link>
</div>
)
},)}
</div>
</div>
2021-04-29 14:18:26 +02:00
</div>
);
}
}
export default ChoixDept