diff --git a/src/client/public/favicon.ico b/src/client/public/favicon.ico index a11777c..b853624 100644 Binary files a/src/client/public/favicon.ico and b/src/client/public/favicon.ico differ diff --git a/src/client/public/react.ico b/src/client/public/react.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/src/client/public/react.ico differ diff --git a/src/client/src/frontpage.js b/src/client/src/FrontPage.js similarity index 95% rename from src/client/src/frontpage.js rename to src/client/src/FrontPage.js index 302c5c6..1111238 100644 --- a/src/client/src/frontpage.js +++ b/src/client/src/FrontPage.js @@ -1,11 +1,11 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; import CreateTournament from "./createtournament.js"; -import TournamentOverview from "./tournamentoverview.js"; +import TournamentOverview from "./TournamentOverview.js"; import TournamentManager from "./managetournament.js"; -import TournamentAnnouncement from "./tournamentannouncement"; -import TournamentMatches from "./tournamentmatches"; -import TeamEditor from "./teameditor"; +import TournamentAnnouncement from "./TournamentAnnouncement"; +import TournamentMatches from "./TournamentMatches"; +import TournamentTeams from "./TournamentTeams"; import Appbar from './components/appbar'; import { Button, Container, Typography, Box } from "@mui/material"; import { Card, CardContent, CardMedia, Paper } from "@mui/material"; @@ -145,7 +145,7 @@ export default function App() { } /> } /> } /> - } /> + } /> } /> +
+

Teams:

+ {/* TODO: scroll denne menyen, eventuelt søkefelt */} + + + + Team Name + Team Members + Actions + + + + {props.teams.map((team) => ( + + + + {team.name} + + {team.members} + + + + + + + ))} + +
+
+ + ); +} + +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({}); + return; + } + fetch(process.env.REACT_APP_BACKEND_URL + `/api/team/${props.selectedTeamId}`) + .then(res => res.json()) + .then(data => { + if (data.status !== "OK") { + showError(data); + return; + } + setTeam(data.data); + }) + .catch(error => showError(error)); + }, [props.selectedTeamId]); + + function postEdit() { + let formData = new FormData(); + formData.append("name", document.getElementById("teamNameInput").value); + } + + if (props.selectedTeamId == -1 || !team) { + return ( + +
+ ... Create a new team or select one from the list above ... +
+
+ ) + } + + function nameInputChanged(event) { + setTeam({...team, name: event.target.value}); + } + + return ( + +
+

Edit Team:

+
+ + + +
+
+ ) +} + +export default function TournamentTeams(props) { + const [teams, setTeams] = React.useState([]); + const [selectedTeamId, setselectedTeamId] = React.useState(-1); + const { tournamentId } = useParams(); + + React.useEffect(() => { + fetch(process.env.REACT_APP_BACKEND_URL + `/api/tournament/${tournamentId}/getTeams`) + .then((res) => res.json()) + .then((data) => { + if (data.status !== "OK") { + showError(data.data); + } + setTeams(data.data); + //setselectedTeamId(teams[0].id); + }) + .catch((err) => showError(err)); + }, []); + + return ( + <> + +
+ + +
+ + ); +} \ No newline at end of file diff --git a/src/client/src/createtournament.js b/src/client/src/createtournament.js index 6d6351a..1d8b71e 100644 --- a/src/client/src/createtournament.js +++ b/src/client/src/createtournament.js @@ -130,18 +130,7 @@ function TournamentForm(props) { - + {/* go brrrr */} diff --git a/src/client/src/index.js b/src/client/src/index.js index 50401f6..680e98a 100644 --- a/src/client/src/index.js +++ b/src/client/src/index.js @@ -1,7 +1,7 @@ import React from "react"; import ReactDOM from "react-dom"; import "./index.css"; -import App from "./frontpage.js"; +import App from "./FrontPage.js"; import theme from './components/theme'; import { ThemeProvider } from "@emotion/react"; diff --git a/src/client/src/managetournament.js b/src/client/src/managetournament.js index a0cd988..285a408 100644 --- a/src/client/src/managetournament.js +++ b/src/client/src/managetournament.js @@ -15,19 +15,19 @@ let submitChanges = curryTournamentId => event => { let tournamentStartDate = document.getElementById("editStartDate").value; let tournamentEndDate = document.getElementById("editEndDate").value; - if (!tournamentName || tournamentName == "") { + if (!tournamentName || tournamentName === "") { alert("Tournament name cannot be empty"); return; } - if (!tournamentDescription || tournamentDescription == "") { + if (!tournamentDescription || tournamentDescription === "") { alert("Tournament description cannot be empty"); return; } - if (!tournamentStartDate || tournamentStartDate == "") { + if (!tournamentStartDate || tournamentStartDate === "") { alert("Tournament start date cannot be empty"); return; } - if (!tournamentEndDate || tournamentEndDate == "") { + if (!tournamentEndDate || tournamentEndDate === "") { alert("Tournament end date cannot be empty"); return; } @@ -88,7 +88,7 @@ function ManageTournament(props) { document.getElementById("editStartDate").value = data.data.startTime.slice(0, 16); document.getElementById("editEndDate").value = data.data.endTime.slice(0, 16); }) - .catch((err) => console.log(err.message)); + .catch((err) => showError(err)); }, []); return ( diff --git a/src/client/src/teameditor.js b/src/client/src/teameditor.js deleted file mode 100644 index d8959b6..0000000 --- a/src/client/src/teameditor.js +++ /dev/null @@ -1,100 +0,0 @@ -import * as React from "react"; -import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; -import Appbar from "./components/appbar"; -import { Button, TextField, MenuItem, InputLabel, Select, Container, Slider} from "@mui/material"; - -function TeamChanger() { - return ( - <> -
- Team Name: - - Team Members: - -
- - - - ); -} -var teams = { - "team 1": ["tom", "eric", "gustav"], - "team 2": ["emma", "mari", "ida"], - "team 3": ["ola", "ole", "ost"], - "team 4": ["christine", "kristine", "kristhine"], -}; -function TeamList(props) { - const [teamInput, setteamInput] = React.useState(""); - const [membersInput, setmembersInput] = React.useState(""); - React.useEffect(() => { - document.getElementById("teamInput").value = teamInput; - document.getElementById("membersInput").value = membersInput; - }); - return ( - <> -
- Registered teams: -
    - {Object.entries(teams).map(([team, players]) => ( -
  • - -
  • - ))} -
-
, -
- Remove team:{" "} - - -
- - {/* Link to {props.tournament.id} when teams can be fetched */} - - - - ); -} - -// function TeamRemover() { -// return ( -// 'lol' -// ); -// } - -// function Save_Button() { -// return ( -// 'lol' -// ); -// } - -export default function TeamEditor() { - return ( - <> - - - - {/* - */} - - ); -}