{matches.map(tier => {
let tierNum = tier[0].tier;
- return
+ return
})}
:
);
}
-function RemovableBar(props) {
- const [endTime, setendTime] = React.useState(null);
-
+export default function TournamentOverview(props) {
+ const { tournamentId } = useParams();
+ const [tournament, setTournament] = React.useState(false);
+
React.useEffect(() => {
- fetch(process.env.REACT_APP_API_URL + `/tournament/${props.tournamentId}`)
+ fetch(process.env.REACT_APP_API_URL + `/tournament/${tournamentId}`)
.then(res => res.json())
.then(data => {
if (data.status !== "OK") {
- // Do your error thing
- console.error(data);
+ showError(data.data);
return;
}
- let endTime = data.data.endTime;
- setendTime(endTime);
+ let tourn = data.data;
+ let now = new Date();
+ let endTime = new Date(tourn.endTime);
+ tourn.hasEnded = (now - 2*60*60*1000) > endTime; // 2 hours in the past
+ setTournament(tourn);
})
.catch(err => showError(err));
- })
- let today = new Date()
- let yesterday = today.setDate(today.getDate() - 1)
- let isComplete = new Date(endTime) < yesterday
- if (isComplete) {
- return (null)
- } else {
- return (
)
- }
-}
-
-
-export default function TournamentOverview(props) {
- const { tournamentId } = useParams();
+ }, [tournamentId]);
return (
<>
-
- { isLoggedIn ?
-
: null
+
+ { isLoggedIn && !tournament.hasEnded ?
+
: null
}
-
+
>
);
}
diff --git a/src/client/src/TournamentTeams.js b/src/client/src/TournamentTeams.js
index 3d24409..90b1487 100644
--- a/src/client/src/TournamentTeams.js
+++ b/src/client/src/TournamentTeams.js
@@ -36,6 +36,7 @@ function TeamCreator(props) {
}
document.getElementById("teamNameInput").value = "";
props.onTeamCreated();
+
}
)
}
@@ -108,14 +109,8 @@ function TeamList(props) {
);
}
-function PlayerList(props) {
- // Something like https://react-list-editable.netlify.app/
- return
PlayerList coming...
-}
-
function TeamEditor(props) {
const [team, setTeam] = React.useState({});
- const [players, setPlayers] = React.useState([]);
React.useEffect(() => {
if (props.selectedTeamId === -1) {
setTeam({});
@@ -180,7 +175,6 @@ function TeamEditor(props) {
Edit Team:
diff --git a/src/client/src/components/SuccessSnackbar.js b/src/client/src/components/SuccessSnackbar.js
new file mode 100644
index 0000000..c71b4de
--- /dev/null
+++ b/src/client/src/components/SuccessSnackbar.js
@@ -0,0 +1,29 @@
+import * as React from 'react';
+import Stack from '@mui/material/Stack';
+import Button from '@mui/material/Button';
+import Snackbar from '@mui/material/Snackbar';
+import MuiAlert from '@mui/material/Alert';
+
+const Alert = React.forwardRef(function Alert(props, ref) {
+ return