ErrorSnackbar (?)
This commit is contained in:
parent
58256fa42b
commit
db9e3e30b8
|
@ -2,17 +2,13 @@ import * as React from "react";
|
||||||
import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom";
|
import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom";
|
||||||
import Appbar from "./components/AsuraBar";
|
import Appbar from "./components/AsuraBar";
|
||||||
import TournamentBar from "./components/TournamentBar";
|
import TournamentBar from "./components/TournamentBar";
|
||||||
|
import ErrorSnackbar from "./components/ErrorSnackbar";
|
||||||
import LoginPage from "./LoginPage";
|
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 { 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 AddCircleIcon from '@mui/icons-material/AddCircle';
|
||||||
import DeleteIcon from '@mui/icons-material/Delete';
|
import DeleteIcon from '@mui/icons-material/Delete';
|
||||||
import EditIcon from '@mui/icons-material/Edit';
|
import EditIcon from '@mui/icons-material/Edit';
|
||||||
|
|
||||||
function showError(error) {
|
|
||||||
alert("Something went wrong. \n" + error);
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
function TeamCreator(props) {
|
function TeamCreator(props) {
|
||||||
function postCreate() {
|
function postCreate() {
|
||||||
let teamName = document.getElementById("teamNameInput").value;
|
let teamName = document.getElementById("teamNameInput").value;
|
||||||
|
@ -183,6 +179,8 @@ function TeamEditor(props) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let showError = (message) => {};
|
||||||
|
|
||||||
export default function TournamentTeams(props) {
|
export default function TournamentTeams(props) {
|
||||||
const [teams, setTeams] = React.useState([]);
|
const [teams, setTeams] = React.useState([]);
|
||||||
const [selectedTeamId, setSelectedTeamId] = React.useState(-1);
|
const [selectedTeamId, setSelectedTeamId] = React.useState(-1);
|
||||||
|
@ -204,6 +202,14 @@ export default function TournamentTeams(props) {
|
||||||
getTeams()
|
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 <LoginPage user={props.user} />; }
|
if (!props.user.isLoggedIn) { return <LoginPage user={props.user} />; }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -215,6 +221,7 @@ export default function TournamentTeams(props) {
|
||||||
<TeamList teams={teams} setTeams={setTeams} selectedTeamId={selectedTeamId} setSelectedTeamId={setSelectedTeamId} />
|
<TeamList teams={teams} setTeams={setTeams} selectedTeamId={selectedTeamId} setSelectedTeamId={setSelectedTeamId} />
|
||||||
<TeamEditor teams={teams} setTeams={setTeams} selectedTeamId={selectedTeamId} setSelectedTeamId={setSelectedTeamId} />
|
<TeamEditor teams={teams} setTeams={setTeams} selectedTeamId={selectedTeamId} setSelectedTeamId={setSelectedTeamId} />
|
||||||
</div>
|
</div>
|
||||||
|
<ErrorSnackbar message={errorMessage} open={openError} setOpen={setOpenError} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
Loading…
Reference in New Issue