From db9e3e30b88bfb8957ada883c9650d76afcc5a92 Mon Sep 17 00:00:00 2001 From: Kristoffer Juelsen Date: Sun, 24 Apr 2022 22:28:02 +0200 Subject: [PATCH] ErrorSnackbar (?) --- src/client/src/TournamentTeams.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/client/src/TournamentTeams.js b/src/client/src/TournamentTeams.js index 83a87cb..fe914bb 100644 --- a/src/client/src/TournamentTeams.js +++ b/src/client/src/TournamentTeams.js @@ -2,17 +2,13 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; import Appbar from "./components/AsuraBar"; import TournamentBar from "./components/TournamentBar"; +import ErrorSnackbar from "./components/ErrorSnackbar"; import LoginPage from "./LoginPage"; import { Button, TextField, Stack, MenuItem, Box, InputLabel, Select, Container, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Paper, Typography} from "@mui/material"; import AddCircleIcon from '@mui/icons-material/AddCircle'; import DeleteIcon from '@mui/icons-material/Delete'; import EditIcon from '@mui/icons-material/Edit'; -function showError(error) { - alert("Something went wrong. \n" + error); - console.error(error); -} - function TeamCreator(props) { function postCreate() { let teamName = document.getElementById("teamNameInput").value; @@ -183,6 +179,8 @@ function TeamEditor(props) { ) } +let showError = (message) => {}; + export default function TournamentTeams(props) { const [teams, setTeams] = React.useState([]); const [selectedTeamId, setSelectedTeamId] = React.useState(-1); @@ -203,6 +201,14 @@ export default function TournamentTeams(props) { React.useEffect(() => { getTeams() }, []); + + const [openError, setOpenError] = React.useState(false); + const [errorMessage, setErrorMessage] = React.useState(""); + showError = (message) => { + setOpenError(false); + setErrorMessage(message); + setOpenError(true); + } if (!props.user.isLoggedIn) { return ; } @@ -215,6 +221,7 @@ export default function TournamentTeams(props) { + ); } \ No newline at end of file