fixed submit buttons on manage teams page, including autoscroll

This commit is contained in:
Kristoffer Longva Eriksen 2022-04-21 11:52:55 +02:00
parent 6deead1260
commit eb8019d22e
1 changed files with 11 additions and 4 deletions

View File

@ -43,15 +43,18 @@ function TeamCreator(props) {
return ( return (
<Paper sx={{width: "90vw", margin: "10px auto", padding: "15px"}} component={Stack} direction="column"> <Paper sx={{width: "90vw", margin: "10px auto", padding: "15px"}} component={Stack} direction="column">
<div align="center"> <div align="center">
<form>
<TextField id="teamNameInput" sx={{ width: "70%" }} label="Team Name" variant="outlined" /> <TextField id="teamNameInput" sx={{ width: "70%" }} label="Team Name" variant="outlined" />
{/* <Button variant="contained" color="primary" onClick={postCreate}>Create Team</Button> */} {/* <Button variant="contained" color="primary" onClick={postCreate}>Create Team</Button> */}
<Button variant="contained" color="success" onClick={postCreate} sx={{width: "20%", marginLeft: "5px"}}> <Button type="submit" variant="contained" color="success" onClick={postCreate} sx={{width: "20%", marginLeft: "5px"}}>
<Box sx={{padding: "10px"}}> <Box sx={{padding: "10px"}}>
Create Team Create Team
</Box> </Box>
<AddCircleIcon /> <AddCircleIcon />
</Button> </Button>
</form>
</div> </div>
</Paper> </Paper>
) )
} }
@ -92,7 +95,7 @@ function TeamList(props) {
</b></TableCell> </b></TableCell>
{/* <TableCell align="right">{team.members}</TableCell> */} {/* <TableCell align="right">{team.members}</TableCell> */}
<TableCell align="center"> <TableCell align="center">
<Button variant="contained" sx={{margin: "auto 5px"}} color="primary" onClick={() => props.setSelectedTeamId(team.id)} endIcon={<EditIcon />}>Edit</Button> <Button variant="contained" sx={{margin: "auto 5px"}} color="primary" onClick={() => {props.setSelectedTeamId(team.id); window.scrollTo(0, document.body.scrollHeight)}} endIcon={<EditIcon />}>Edit</Button>
<Button variant="contained" sx={{margin: "auto 5px"}} color="error" onClick={() => {deleteTeam(team.id)}} endIcon={<DeleteIcon />}>Delete</Button> <Button variant="contained" sx={{margin: "auto 5px"}} color="error" onClick={() => {deleteTeam(team.id)}} endIcon={<DeleteIcon />}>Delete</Button>
</TableCell> </TableCell>
</TableRow> </TableRow>
@ -146,6 +149,10 @@ function TeamEditor(props) {
setTeam(newTeam); setTeam(newTeam);
} }
function handleFocus(event) {
event.currentTarget.select()
}
function saveTeam() { function saveTeam() {
let formData = new FormData(); let formData = new FormData();
formData.append("name", team.name); formData.append("name", team.name);
@ -172,9 +179,9 @@ function TeamEditor(props) {
<div align="center"> <div align="center">
<h2><b>Edit Team:</b></h2> <h2><b>Edit Team:</b></h2>
<form> <form>
<TextField id="teamNameInput" label="Team Name" value={team.name || ""} onChange={nameInputChanged} sx={{width: "80%"}} /> <TextField id="newTeamNameInput" label="Team Name" value={team.name || ""} onChange={nameInputChanged} onFocus={handleFocus} sx={{width: "80%"}} />
{/* <PlayerList players={players} setPlayers={setPlayers} /> */} {/* <PlayerList players={players} setPlayers={setPlayers} /> */}
<Button variant="contained" sx={{margin: "auto 5px"}} color="primary" onClick={saveTeam}>Save</Button> <Button type="submit" variant="contained" sx={{margin: "auto 5px"}} color="primary" onClick={saveTeam}>Save</Button>
</form> </form>
</div> </div>
</Paper> </Paper>