mirror of
https://gitlab.aliens-lyon.fr/encartes/web-interface.git
synced 2026-03-17 22:51:04 +01:00
Edit dialog
This commit is contained in:
parent
df2d531467
commit
381ed82185
46
src/App.js
46
src/App.js
@ -85,19 +85,25 @@ function RoomResearch({ callbackRoomSelected }) {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function RoomInformation({ roomId }) {
|
function RoomInformation({ roomId, setIsEditDialogOpen }) {
|
||||||
const [names, setNames] = React.useState([]);
|
const [names, setNames] = React.useState([]);
|
||||||
const [users, setUsers] = React.useState([]);
|
const [users, setUsers] = React.useState([]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
fetch("https://encartes.aliens-lyon.fr/api/map/get_place_info/" + roomId)
|
if (roomId !== null) {
|
||||||
.then(response => response.json())
|
fetch("https://encartes.aliens-lyon.fr/api/map/get_place_info/" + roomId)
|
||||||
.then(data => {
|
.then(response => response.json())
|
||||||
setNames(data.names);
|
.then(data => {
|
||||||
setUsers(data.users);
|
setNames(data.names);
|
||||||
});
|
setUsers(data.users);
|
||||||
|
});
|
||||||
|
}
|
||||||
}, [roomId]);
|
}, [roomId]);
|
||||||
|
|
||||||
|
if (roomId === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return <div style={{ padding: '24px' }}>
|
return <div style={{ padding: '24px' }}>
|
||||||
<Typography component="h2" variant="h5" gutterBottom>
|
<Typography component="h2" variant="h5" gutterBottom>
|
||||||
Salle sélectionnée
|
Salle sélectionnée
|
||||||
@ -112,6 +118,7 @@ function RoomInformation({ roomId }) {
|
|||||||
: 'Utilisée par ' + users.join(', ')
|
: 'Utilisée par ' + users.join(', ')
|
||||||
}</li>
|
}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<a onClick={() => { setIsEditDialogOpen(true) }}>Modifier</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,12 +164,32 @@ function TopBar() {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EditDialog({ isOpen, setIsOpen, room }) { // onClose={handleClose}
|
||||||
|
return <Dialog open={isOpen} onClose={() => { setIsOpen(false) }}>
|
||||||
|
<DialogTitle>Salle n°{room}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText>
|
||||||
|
Noms :
|
||||||
|
</DialogContentText>
|
||||||
|
<TextField label="Nouveau nom" margin="dense" fullWidth />
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={() => { setIsOpen(false) }}>Fermer</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
}
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [currentFloor, setCurrentFloor] = React.useState(6);
|
const [currentFloor, setCurrentFloor] = React.useState(6);
|
||||||
const [selectedRoom, setSelectedRoom] = React.useState(null);
|
const [selectedRoom, setSelectedRoom] = React.useState(null);
|
||||||
|
const [isEditDialogOpen, setIsEditDialogOpen] = React.useState(false);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
<EditDialog
|
||||||
|
isOpen={isEditDialogOpen}
|
||||||
|
setIsOpen={setIsEditDialogOpen}
|
||||||
|
room={selectedRoom}
|
||||||
|
/>
|
||||||
<TopBar />
|
<TopBar />
|
||||||
<div style={{ flexGrow: '1', display: 'flex', flexDirection: 'line', flexWrap: 'nowrap' }}>
|
<div style={{ flexGrow: '1', display: 'flex', flexDirection: 'line', flexWrap: 'nowrap' }}>
|
||||||
<Map
|
<Map
|
||||||
@ -179,7 +206,10 @@ export default function App() {
|
|||||||
setSelectedRoom(room);
|
setSelectedRoom(room);
|
||||||
}} />
|
}} />
|
||||||
<Divider />
|
<Divider />
|
||||||
<RoomInformation roomId={selectedRoom} />
|
<RoomInformation
|
||||||
|
roomId={selectedRoom}
|
||||||
|
setIsEditDialogOpen={setIsEditDialogOpen}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user