Request to get the name of the floors

This commit is contained in:
Adrien Vannson 2023-03-01 09:59:29 +01:00
parent 62d297a0a3
commit 5156cfcff5
No known key found for this signature in database
GPG Key ID: FE2E66FD978C1A55

View File

@ -25,25 +25,44 @@ import Map from './Map.js';
import Rooms from './Rooms.js';
function ChangeFloor({ currentFloor, callbackFloorChanged }) {
const [sites, setSites] = React.useState([]);
const handleFloorChanged = (event) => {
callbackFloorChanged(event.target.value);
};
React.useEffect(() => {
fetch("https://encartes.aliens-lyon.fr/api/map/get_all_floors/")
.then(response => response.json())
.then(data => {
setSites(data);
});
}, []);
var items = [];
sites.forEach(site => {
site.buildings.forEach(building => {
building.floors.forEach(floor => {
items.push(
<MenuItem value={floor.id}>{site.name} / {building.name} / {floor.name}</MenuItem>
)
})
})
});
return <>
<div style={{ padding: '24px' }}>
<Typography component="h2" variant="h5" gutterBottom>
Changer d'étage
</Typography>
<Select
value={currentFloor}
label="Étage"
onChange={handleFloorChanged}
fullWidth
>
<MenuItem value={9}>Monod - Premier étage</MenuItem>
<MenuItem value={13}>Monod - Troisième étage</MenuItem>
<MenuItem value={14}>Monod - Quatrième étage</MenuItem>
{items}
</Select>
</div>
</>