From a283ae90b08f5d24fef71b30d488433e2e25d3f0 Mon Sep 17 00:00:00 2001 From: Kristoffer Longva Eriksen Date: Thu, 21 Apr 2022 10:34:57 +0200 Subject: [PATCH] disabled editing of archived tournaments --- src/client/src/TournamentOverview.js | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/client/src/TournamentOverview.js b/src/client/src/TournamentOverview.js index f89c410..ea162b4 100644 --- a/src/client/src/TournamentOverview.js +++ b/src/client/src/TournamentOverview.js @@ -176,6 +176,33 @@ function BracketViewer(props) { ); } +function RemovableBar(props) { + const [endTime, setendTime] = React.useState(null); + + React.useEffect(() => { + fetch(process.env.REACT_APP_API_URL + `/tournament/${props.tournamentId}`) + .then(res => res.json()) + .then(data => { + if (data.status !== "OK") { + // Do your error thing + console.error(data); + return; + } + let endTime = data.data.endTime; + setendTime(endTime); + }) + .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 () + } +} + function showError(error) { alert("Something went wrong. \n" + error); console.error(error); @@ -187,7 +214,7 @@ export default function TournamentOverview(props) { return ( <> - + );