From 606c97a68e264407157005e43976bbaea94f2c10 Mon Sep 17 00:00:00 2001 From: Adrien Vannson Date: Wed, 1 Mar 2023 09:34:02 +0100 Subject: [PATCH] Add names to rooms --- src/App.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index e0daa32..598a310 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import * as React from 'react'; import AppBar from '@mui/material/AppBar'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; +import Chip from '@mui/material/Chip'; import CssBaseline from '@mui/material/CssBaseline'; import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; @@ -164,14 +165,60 @@ function TopBar() { } -function EditDialog({ isOpen, setIsOpen, room }) { // onClose={handleClose} +function EditDialog({ isOpen, setIsOpen, room }) { + const [names, setNames] = React.useState([]); + const [users, setUsers] = React.useState([]); + const [newPlaceName, setNewPlaceName] = React.useState(""); + + // Used to refresh useEffect + const [updatesCount, setupdatesCount] = React.useState(0); + + React.useEffect(() => { + if (room !== null) { + fetch("https://encartes.aliens-lyon.fr/api/map/get_place_info/" + room) + .then(response => response.json()) + .then(data => { + setNames(data.names); + setUsers(data.users); + }); + } + }, [room, updatesCount]); + + const refresh = () => { + setupdatesCount(updatesCount + 1); + }; + + const addName = () => { + fetch("https://encartes.aliens-lyon.fr/api/map/add_place_name/" + room + "/" + encodeURI(newPlaceName)) + .then(response => refresh()); + }; + return { setIsOpen(false) }}> Salle n°{room} - Noms : + Noms :
+ {names.map(name => { + return {}} /> + })} + + { setNewPlaceName(event.target.value) }} + label="Nouveau nom" + margin="dense" + fullWidth + /> + + + + + Utilisateurs :
+ {users.map(name => { + return {}} /> + })}
- +