diff --git a/src/client/src/AdminsOverview.js b/src/client/src/AdminsOverview.js index ff13fbf..5af86a4 100644 --- a/src/client/src/AdminsOverview.js +++ b/src/client/src/AdminsOverview.js @@ -3,10 +3,12 @@ import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-r import Appbar from "./components/AsuraBar"; import ErrorSnackbar from "./components/ErrorSnackbar"; import LoginPage from "./LoginPage"; -import {Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography, Select, MenuItem, FormControl} from '@mui/material'; +import { Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography, Select, MenuItem, FormControl } from '@mui/material'; +import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from "@mui/material"; import AddCircleIcon from '@mui/icons-material/AddCircle'; import DeleteIcon from '@mui/icons-material/Delete'; import EditIcon from '@mui/icons-material/Edit'; +import PropTypes from 'prop-types' function AdminCreator(props){ function postCreate(){ @@ -55,17 +57,20 @@ function AdminCreator(props){ } function UserList(props){ - const deleteUsers = (userId) => { + const deleteUser = (userId) => { + openConfirmDialog(function() { fetch(process.env.REACT_APP_API_URL + `/users/${userId}`, {method: "DELETE"}) .then(res => res.json()) .then(data => { if(data.status !== "OK"){ showError(data.data); + console.log("UWU") return; } - props.setUsers(props.users.filter(user => user.id !== userId)); + props.onUserUpdated(); }) .catch(error => showError(error)); + }); } let updateRank = (asuraId) => event => { @@ -92,52 +97,99 @@ function UserList(props){ return(
- {/* TODO: scroll denne menyen, eventuelt søkefelt */} - - - - Name - Email - Rank - Actions +
+ + + Name + Email + Rank + Actions + + + + {props.users.map((user) => ( + + + + {user.name} + + + {user.email} + {/* TODO Drop down menu for selecting rank */} + + + + + + {/* {team.members} */} + + {/* */} + + - - - {props.users.map((user) => ( - - - - {user.name} - - - {user.email} - {/* TODO Drop down menu for selecting rank */} - - - - - - {/* {team.members} */} - - {/* */} - - - - ))} - -
+ ))} + +
) } +function ConfirmationDialogRaw(props) { + const { userId } = useParams(); + const { onClose, value: valueProp, open, ...other } = props; + const [value, setValue] = React.useState(valueProp); + + React.useEffect(() => { + if (!open) { + setValue(valueProp); + } + }, [valueProp, open]); + + const handleCancel = () => { + onClose(); + }; + const handleConfirm = () => { + onClose(); + props.handleconfirm(); + }; + + return ( + + Delete administrator? + + Are you sure you want to delete the administrator? This action is not reversible! + + + + + + + ); +} + +ConfirmationDialogRaw.propTypes = { + onClose: PropTypes.func.isRequired, + open: PropTypes.bool.isRequired, +}; + +// Confirmation window for "Delete user" +function openConfirmDialog(callback) {g_setDialogCallback(callback); g_setDialogOpen(true);} +let g_setDialogOpen = () => {}; +let g_setDialogCallback = (callback) => {}; + let showError = (message) => {}; - - export default function Users(props) { const [openError, setOpenError] = React.useState(false); @@ -149,6 +201,12 @@ export default function Users(props) { } const [users, setUsers] = React.useState([]); + const [dialogOpen, setDialogOpen] = React.useState(false); + const handleDialogClose = () => { setDialogOpen(false); }; + const [dialogOnConfirm, setDialogOnConfirm] = React.useState(() => {return function(){}}); + g_setDialogCallback = (callback) => { setDialogOnConfirm(()=>{ return callback })}; + g_setDialogOpen = (value) => { setDialogOpen(value); }; + function getUsers() { fetch(process.env.REACT_APP_API_URL + `/users/getUsers`) .then((res) => res.json()) @@ -186,6 +244,13 @@ export default function Users(props) { + ); } \ No newline at end of file diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 4f79a25..7f39591 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -182,7 +182,7 @@ function Home(props) { <> - + Tournaments { props.user.isLoggedIn ? : null diff --git a/src/client/src/TournamentManager.js b/src/client/src/TournamentManager.js index cbae582..02f9a8e 100644 --- a/src/client/src/TournamentManager.js +++ b/src/client/src/TournamentManager.js @@ -219,8 +219,13 @@ export default function TournamentManager(props) { const handleDialogClickListItem = () => { setDialogOpen(true); }; const handleDialogClose = () => { setDialogOpen(false); }; - showError = props.showError; - showSuccess = props.showSuccess; + const [openError, setOpenError] = React.useState(false); + const [errorMessage, setErrorMessage] = React.useState(""); + showError = (message) => { + setOpenError(false); + setErrorMessage(message); + setOpenError(true); + } if (!props.user.isLoggedIn) { return ; } @@ -229,7 +234,7 @@ export default function TournamentManager(props) { - + {/* */} - { props.user.isManager && } + ); diff --git a/src/client/src/components/TournamentBar.js b/src/client/src/components/TournamentBar.js index 06914a4..62afe4d 100644 --- a/src/client/src/components/TournamentBar.js +++ b/src/client/src/components/TournamentBar.js @@ -3,6 +3,11 @@ import { useParams } from "react-router-dom"; import { BrowserRouter as Router, Link, Route, Routes, History } from "react-router-dom"; import { Stack, Paper, Typography, Box, Button, Grid, Snackbar, IconButton } from "@mui/material" import CloseIcon from '@mui/icons-material/Close'; +import MuiAlert from '@mui/material/Alert'; + +const Alert = React.forwardRef(function Alert(props, ref) { + return ; +}); function ClipboardButton(props) { const [open, setOpen] = React.useState(false); @@ -23,7 +28,11 @@ function ClipboardButton(props) { return ( <> - + + + {props.name + " copied to clipboard"} + + ); } diff --git a/src/client/src/components/tournamentBracket.css b/src/client/src/components/tournamentBracket.css index 2823d19..193154f 100644 --- a/src/client/src/components/tournamentBracket.css +++ b/src/client/src/components/tournamentBracket.css @@ -6,7 +6,7 @@ flex-direction:row; justify-content: center; } - .round{ +.round{ display:flex; flex-direction:column; justify-content:center; @@ -14,13 +14,13 @@ list-style:none; padding:0; /* font-size: 1.5rem; */ - } - .round .spacer{ flex-grow:1;} - .round .spacer:first-child, - .round .spacer:last-child{ flex-grow:.5; } - .round .game-spacer{ - flex-grow:1; - } +} +.round .spacer{ flex-grow:1;} +.round .spacer:first-child, +.round .spacer:last-child{ flex-grow:.5; } +.round .game-spacer{ + flex-grow:1; +} /* * General Styles @@ -32,26 +32,44 @@ line-height:1.4em; } */ - li.game{ +li.game{ padding-left:20px; - } +} - .winner{ - color:green; - font-weight: bold; - } - .loser{ - color:grey; - } +.winner{ + color:green; + font-weight: bold; +} +.loser{ + color:grey; +} - li.game-top{ border-bottom:1px solid #aaa; } +li.game-top{ border-bottom:1px solid #aaa; } - li.game-spacer{ - border-right:1px solid #aaa; - min-height:10vh; - } +li.game-spacer{ + border-right:1px solid #aaa; + min-height:10vh; +} - li.game-bottom{ - border-top:1px solid #aaa; - } - \ No newline at end of file +li.game-bottom{ + border-top:1px solid #aaa; +} + + +.winnerDisplay { + display:flex; + flex-direction:row; + align-items: center; + border: 2px solid gray; + border-radius: 15px; + min-height: 10vh; + max-height: 40vh; + margin: auto 5px; + padding: 10px; +} +.winnerDisplay.winner { + border: 2px solid green; +} +.winnerDisplay > h2 { + margin-right: 10px; +} \ No newline at end of file