mirror of
https://gitlab.aliens-lyon.fr/encartes/web-interface.git
synced 2026-03-18 07:01:05 +01:00
Request to get the name of the floors
This commit is contained in:
parent
62d297a0a3
commit
5156cfcff5
27
src/App.js
27
src/App.js
@ -25,25 +25,44 @@ import Map from './Map.js';
|
|||||||
import Rooms from './Rooms.js';
|
import Rooms from './Rooms.js';
|
||||||
|
|
||||||
function ChangeFloor({ currentFloor, callbackFloorChanged }) {
|
function ChangeFloor({ currentFloor, callbackFloorChanged }) {
|
||||||
|
const [sites, setSites] = React.useState([]);
|
||||||
const handleFloorChanged = (event) => {
|
const handleFloorChanged = (event) => {
|
||||||
callbackFloorChanged(event.target.value);
|
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 <>
|
return <>
|
||||||
<div style={{ padding: '24px' }}>
|
<div style={{ padding: '24px' }}>
|
||||||
<Typography component="h2" variant="h5" gutterBottom>
|
<Typography component="h2" variant="h5" gutterBottom>
|
||||||
Changer d'étage
|
Changer d'étage
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
value={currentFloor}
|
value={currentFloor}
|
||||||
label="Étage"
|
label="Étage"
|
||||||
onChange={handleFloorChanged}
|
onChange={handleFloorChanged}
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value={9}>Monod - Premier étage</MenuItem>
|
{items}
|
||||||
<MenuItem value={13}>Monod - Troisième étage</MenuItem>
|
|
||||||
<MenuItem value={14}>Monod - Quatrième étage</MenuItem>
|
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user