mirror of
https://gitlab.aliens-lyon.fr/encartes/web-interface.git
synced 2026-03-17 22:51:04 +01:00
Research room
This commit is contained in:
parent
3f1fdaa619
commit
d3078f2c43
23
src/App.js
23
src/App.js
@ -50,21 +50,38 @@ function ChangeFloor({ currentFloor, callbackFloorChanged }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RoomResearch({ callbackRoomSelected }) {
|
function RoomResearch({ callbackRoomSelected }) {
|
||||||
|
const [currentRequest, setCurrentRequest] = React.useState("");
|
||||||
|
const [rooms, setRooms] = React.useState([]);
|
||||||
|
|
||||||
|
const startResearch = (event) => {
|
||||||
|
fetch("https://encartes.aliens-lyon.fr/api/map/find_place_by_name/" + currentRequest)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
setRooms(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<div style={{ padding: '24px' }}>
|
<div style={{ padding: '24px' }}>
|
||||||
<Typography component="h2" variant="h5" gutterBottom>
|
<Typography component="h2" variant="h5" gutterBottom>
|
||||||
Rechercher une salle
|
Rechercher une salle
|
||||||
</Typography>
|
</Typography>
|
||||||
<TextField id="outlined-basic" label="Nom, code, occupants, ..." variant="outlined" fullWidth />
|
<TextField
|
||||||
|
label="Nom, code, occupants, ..."
|
||||||
|
value={currentRequest}
|
||||||
|
onChange={(event) => {setCurrentRequest(event.target.value)}}
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
<Box
|
<Box
|
||||||
marginTop={1}
|
marginTop={1}
|
||||||
display="flex"
|
display="flex"
|
||||||
justifyContent="flex-end"
|
justifyContent="flex-end"
|
||||||
alignItems="flex-end"
|
alignItems="flex-end"
|
||||||
>
|
>
|
||||||
<Button variant="contained">Rechercher</Button>
|
<Button variant="contained" onClick={startResearch}>Rechercher</Button>
|
||||||
</Box>
|
</Box>
|
||||||
<Rooms callbackRoomSelected={callbackRoomSelected} />
|
<Rooms rooms={rooms} callbackRoomSelected={callbackRoomSelected} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/Rooms.js
16
src/Rooms.js
@ -5,24 +5,20 @@ import TableRow from '@mui/material/TableRow';
|
|||||||
import TableCell from '@mui/material/TableCell';
|
import TableCell from '@mui/material/TableCell';
|
||||||
import TableBody from '@mui/material/TableBody';
|
import TableBody from '@mui/material/TableBody';
|
||||||
|
|
||||||
export default function Rooms({callbackRoomSelected}) {
|
export default function Rooms({rooms, callbackRoomSelected}) {
|
||||||
return <TableContainer variant="outlined">
|
return <TableContainer variant="outlined">
|
||||||
<Table aria-label="demo table">
|
<Table aria-label="demo table">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell>Salle</TableCell>
|
<TableCell>Salle</TableCell>
|
||||||
<TableCell>Occupants</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow hover={true} onClick={() => callbackRoomSelected('salle-M-GN1-3-av')}>
|
{rooms.map((room) => {
|
||||||
<TableCell>Amphi A</TableCell>
|
return <TableRow hover={true} onClick={() => callbackRoomSelected(room['idRoom'])}>
|
||||||
<TableCell>Maths</TableCell>
|
<TableCell>{room['idRoom']}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow hover={true} onClick={() => callbackRoomSelected('salle-M-GN1-3-ae')}>
|
})}
|
||||||
<TableCell>Amphi B</TableCell>
|
|
||||||
<TableCell>Infos</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user