Tournament editor
This commit is contained in:
parent
99e027f470
commit
aabf4f4ece
|
@ -5,12 +5,13 @@ import Appbar from "./components/appbar";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { Button, TextField, MenuItem, InputLabel, Select, Container, Slider} from "@mui/material";
|
import { Button, TextField, MenuItem, InputLabel, Select, Container, Slider} from "@mui/material";
|
||||||
|
|
||||||
function submitChanges(event) {
|
let submitChanges = curryTournamentId => event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
let tournamentId = curryTournamentId;
|
||||||
//TODO use refs to get values
|
//TODO use refs to get values
|
||||||
let tournamentName = document.getElementById("editName").value;
|
let tournamentName = document.getElementById("editName").value;
|
||||||
let tournamentDescription = document.getElementById("editDesc").value;
|
let tournamentDescription = document.getElementById("editDesc").value;
|
||||||
let tournamentImageFile = document.getElementById("editImage").files[0];
|
// let tournamentImageFile = document.getElementById("editImage").files[0];
|
||||||
let tournamentStartDate = document.getElementById("editStartDate").value;
|
let tournamentStartDate = document.getElementById("editStartDate").value;
|
||||||
let tournamentEndDate = document.getElementById("editEndDate").value;
|
let tournamentEndDate = document.getElementById("editEndDate").value;
|
||||||
|
|
||||||
|
@ -50,15 +51,15 @@ function submitChanges(event) {
|
||||||
// formData.append("teamLimit", tournamentMaxTeams);
|
// formData.append("teamLimit", tournamentMaxTeams);
|
||||||
let body = new URLSearchParams(formData);
|
let body = new URLSearchParams(formData);
|
||||||
|
|
||||||
fetch(process.env.REACT_APP_BACKEND_URL + "/api/tournament/create", {
|
fetch(process.env.REACT_APP_BACKEND_URL + `/api/tournament/${tournamentId}/edit`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: body,
|
body: body,
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.status == "OK") {
|
if (data.status === "OK") {
|
||||||
alert("Tournament managed successfully");
|
alert("Tournament Changed successfully");
|
||||||
window.location.href = "/";
|
window.location.href = `/tournament/${tournamentId}`;
|
||||||
} else {
|
} else {
|
||||||
showError(data.data);
|
showError(data.data);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ function ManageTournament(props) {
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={submitChanges}
|
onClick={submitChanges(props.tournamentId)}
|
||||||
color="primary"
|
color="primary"
|
||||||
>
|
>
|
||||||
Save Tournament Details
|
Save Tournament Details
|
||||||
|
|
Loading…
Reference in New Issue