From 4d1ee2de6260ec185942b50e00f01414653cfa78 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Tue, 29 Mar 2022 01:12:15 +0200 Subject: [PATCH] Fix slider --- src/client/src/TournamentCreator.js | 93 +++++++++-------------------- 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/src/client/src/TournamentCreator.js b/src/client/src/TournamentCreator.js index b199dc1..483e0df 100644 --- a/src/client/src/TournamentCreator.js +++ b/src/client/src/TournamentCreator.js @@ -5,15 +5,10 @@ import Appbar from "./components/appbar"; import { Button, TextField, Stack, InputLabel, Select, Container, Slider, Paper, Box, Grid, Typography } from '@mui/material' import FileUploadIcon from '@mui/icons-material/FileUpload'; -function submitTournament(event) { - event.preventDefault(); +function postTournament(tournamentName, tournamentDescription, tournamentStartDate, tournamentEndDate, tournamentMaxTeams) { + // event.preventDefault(); //TODO use refs to get values - let tournamentName = document.getElementById("nameInput").value; - let tournamentDescription = document.getElementById("descriptionInput").value; - let tournamentImageFile = document.getElementById("editImage").files[0]; - let tournamentStartDate = document.getElementById("startDatePicker").value; - let tournamentEndDate = document.getElementById("endDatePicker").value; - let tournamentMaxTeams = document.getElementById("max-teams-select").value; + if (!tournamentName || tournamentName == "") { alert("Tournament name cannot be empty"); @@ -80,36 +75,32 @@ function showError(error) { } function TournamentForm(props) { - + const [maxTeamsExponent, setMaxTeamsExponent] = React.useState(1); + function sliderUpdate(event) { + setMaxTeamsExponent(event.target.value); + } + + function submitTournament(event) { + event.preventDefault(); + console.log(maxTeamsExponent) + let maxTeams = Math.pow(2, maxTeamsExponent); + postTournament( + document.getElementById("nameInput").value, + document.getElementById("descriptionInput").value, + document.getElementById("startDatePicker").value, + document.getElementById("endDatePicker").value, + maxTeams + ); + } + const marks = [ - { - value: 1, - label: "2", - }, - { - value: 2, - label: "4", - }, - { - value: 3, - label: "8", - }, - { - value: 4, - label: "16", - }, - { - value: 5, - label: "32", - }, - { - value: 6, - label: "64", - }, - { - value: 7, - label: "128", - }, + { value: 1, label: "2",}, + { value: 2, label: "4",}, + { value: 3, label: "8",}, + { value: 4, label: "16",}, + { value: 5, label: "32",}, + { value: 6, label: "64",}, + { value: 7, label: "128",} ]; return ( @@ -144,38 +135,12 @@ function TournamentForm(props) { Maximum number of teams - {/* */} - {/* */} - +