More date input updates

This commit is contained in:
Kristoffer Juelsenn 2022-04-09 11:05:26 +02:00
parent 6774868dfc
commit 3d34acc77a
2 changed files with 27 additions and 41 deletions

View File

@ -82,14 +82,14 @@ function TournamentForm(props) {
event.preventDefault(); event.preventDefault();
console.log(maxTeamsExponent) console.log(maxTeamsExponent)
let maxTeams = Math.pow(2, maxTeamsExponent); let maxTeams = Math.pow(2, maxTeamsExponent);
let startTime = new Date(startTime).toUTCString(); let tournamentStart = new Date(startTime).toUTCString();
let endTime = new Date(endTime).toUTCString(); let tournamentEnd = new Date(endTime).toUTCString();
postTournament( postTournament(
props.showError, props.showError,
document.getElementById("nameInput").value, document.getElementById("nameInput").value,
document.getElementById("descriptionInput").value, document.getElementById("descriptionInput").value,
startTime, tournamentStart,
endTime, tournamentEnd,
maxTeams maxTeams
); );
console.log(startTime, endTime); console.log(startTime, endTime);
@ -114,33 +114,19 @@ function TournamentForm(props) {
<TextField type="text" multiline={true} id="descriptionInput" label="Description" placeholder="Description" InputLabelProps={{shrink: true}}/> <TextField type="text" multiline={true} id="descriptionInput" label="Description" placeholder="Description" InputLabelProps={{shrink: true}}/>
<Box> <Box>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker <DateTimePicker label={"Start Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm" inputFormat="yyyy-MM-dd HH:mm" value={startTime}
label={"Start Time"}
inputVariant="outlined"
ampm={false}
mask="____-__-__ __:__"
format="yyyy-MM-dd HH:mm"
inputFormat="yyyy-MM-dd HH:mm"
value={startTime}
onChange={(newValue) => { onChange={(newValue) => {
setStartTime(newValue); setStartTime(newValue);
console.log(new Date(newValue).toUTCString()); // console.log(new Date(newValue).toUTCString());
}} }}
renderInput={(params) => <TextField id="startDatePicker" {...params} />} renderInput={(params) => <TextField id="startDatePicker" {...params} />}
/> />
</LocalizationProvider> </LocalizationProvider>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker <DateTimePicker label={"End Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm" inputFormat="yyyy-MM-dd HH:mm" value={endTime}
label={"End Time"}
inputVariant="outlined"
ampm={false}
mask="____-__-__ __:__"
format="yyyy-MM-dd HH:mm"
inputFormat="yyyy-MM-dd HH:mm"
value={endTime}
onChange={(newValue) => { onChange={(newValue) => {
setEndTime(newValue); setEndTime(newValue);
console.log(new Date(newValue).toUTCString()); // console.log(new Date(newValue).toUTCString());
}} }}
renderInput={(params) => <TextField id="endDatePicker" {...params} />} renderInput={(params) => <TextField id="endDatePicker" {...params} />}
/> />

View File

@ -131,25 +131,25 @@ function ManageTournament(props) {
<Stack sx={{minHeight: "30vh", margin: "10px auto"}} direction="column" justifyContent="center" spacing={2} align="center"> <Stack sx={{minHeight: "30vh", margin: "10px auto"}} direction="column" justifyContent="center" spacing={2} align="center">
<TextField type="text" id="editName" label="Edit Name:" placeholder="Edit Name" InputLabelProps={{shrink: true}}/> <TextField type="text" id="editName" label="Edit Name:" placeholder="Edit Name" InputLabelProps={{shrink: true}}/>
<TextField type="text" multiline={true} id="editDesc" label="Edit Description:" placeholder="Edit Description" InputLabelProps={{shrink: true}} /> <TextField type="text" multiline={true} id="editDesc" label="Edit Description:" placeholder="Edit Description" InputLabelProps={{shrink: true}} />
<Box> <Box sx={{flexGrow: 1}}>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker label={"Start Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm" inputFormat="yyyy-MM-dd HH:mm" value={startTime} <DateTimePicker label={"Start Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm" inputFormat="yyyy-MM-dd HH:mm" value={startTime}
onChange={(newValue) => { onChange={(newValue) => {
setStartTime(newValue); setStartTime(newValue);
console.log(new Date(newValue).toUTCString()); console.log(new Date(newValue).toUTCString());
}} }}
renderInput={(params) => <TextField id="editStartDate" {...params} />} renderInput={(params) => <TextField id="editStartDate" {...params} />}
/> />
</LocalizationProvider> </LocalizationProvider>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker label={"End Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm:" inputFormat="yyyy-MM-dd HH:mm" value={endTime} <DateTimePicker label={"End Time"} inputVariant="outlined" ampm={false} mask="____-__-__ __:__" format="yyyy-MM-dd HH:mm:" inputFormat="yyyy-MM-dd HH:mm" value={endTime}
onChange={(newValue) => { onChange={(newValue) => {
setEndTime(newValue); setEndTime(newValue);
console.log(new Date(newValue).toUTCString()); console.log(new Date(newValue).toUTCString());
}} }}
renderInput={(params) => <TextField id="editEndDate" {...params} />} renderInput={(params) => <TextField id="editEndDate" {...params} />}
/> />
</LocalizationProvider> </LocalizationProvider>
</Box> </Box>
{/* <TextField type="datetime-local" id="editStartDate" label="Edit Start Time" InputLabelProps={{shrink: true,}}/> {/* <TextField type="datetime-local" id="editStartDate" label="Edit Start Time" InputLabelProps={{shrink: true,}}/>
<TextField type="datetime-local" id="editEndDate" label="Edit End Time" InputLabelProps={{shrink: true}}/> */} <TextField type="datetime-local" id="editEndDate" label="Edit End Time" InputLabelProps={{shrink: true}}/> */}