minor update, api endpoint moved

This commit is contained in:
Felix Albrigtsen 2022-04-24 13:57:30 +02:00
parent 5aaa5ff7a6
commit 2a8dfd0cbf
2 changed files with 11 additions and 12 deletions

View File

@ -61,7 +61,7 @@ function AdminCreator(props){
} }
function UserList(props){ function UserList(props){
const deleteUsers = userId => { const deleteUsers = (userId) => {
fetch(process.env.REACT_APP_API_URL + `/users/${userId}`, {method: "DELETE"}) fetch(process.env.REACT_APP_API_URL + `/users/${userId}`, {method: "DELETE"})
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
@ -74,13 +74,12 @@ function UserList(props){
.catch(error => showError(error)); .catch(error => showError(error));
} }
let updateRank = (email) => event => { let updateRank = (asuraId) => event => {
let isManager = event.target.value == "manager"; let isManager = event.target.value == "manager";
let formData = new FormData(); let formData = new FormData();
formData.append("isManager", isManager); formData.append("isManager", isManager);
formData.append("emailAddress", email);
let body = new URLSearchParams(formData); let body = new URLSearchParams(formData);
fetch(process.env.REACT_APP_API_URL + `/users/changeManagerStatus`, { fetch(process.env.REACT_APP_API_URL + `/users/${asuraId}/changeManagerStatus`, {
method: "POST", method: "POST",
body: body body: body
}) })
@ -119,7 +118,7 @@ function UserList(props){
<TableCell>{user.email}</TableCell> <TableCell>{user.email}</TableCell>
{/* TODO Drop down menu for selecting rank */} {/* TODO Drop down menu for selecting rank */}
<TableCell> <TableCell>
<select onChange={updateRank(user.email)} value={user.isManager ? "manager" : "admin"}> <select onChange={updateRank(user.asuraId)} value={user.isManager ? "manager" : "admin"}>
<option value="manager">Manager</option> <option value="manager">Manager</option>
<option value="admin">Admin</option> <option value="admin">Admin</option>
</select> </select>
@ -127,7 +126,7 @@ function UserList(props){
{/* <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)} endIcon={<EditIcon />}>Edit</Button> */}
<Button variant="contained" sx={{margin: "auto 5px"}} color="error" onClick={() => {deleteUsers(user.id)}} endIcon={<DeleteIcon />}>Delete</Button> <Button variant="contained" sx={{margin: "auto 5px"}} color="error" onClick={() => {deleteUsers(user.asuraId)}} endIcon={<DeleteIcon />}>Delete</Button>
</TableCell> </TableCell>
</TableRow> </TableRow>
))} ))}

View File

@ -89,15 +89,15 @@ function Match(props){
<Typography className={`teamName`} align={'center'} sx={{fontSize:'1.5rem', maxWidth:'15vw', overflow:'hidden', wordWrap:'none'}}> <Typography className={`teamName`} align={'center'} sx={{fontSize:'1.5rem', maxWidth:'15vw', overflow:'hidden', wordWrap:'none'}}>
{team1Name} {team1Name}
</Typography> </Typography>
{ props.match.winnerId && (props.match.team1Id === props.match.winnerId) &&
<EmojiEventsIcon alt="A trohpy" color="gold" />
}
{ props.match.team1Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn && { props.match.team1Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn &&
<IconButton color="error" aria-label="remmove winner" component="span" onClick={curryUnsetContestant(props.match.team1Id)}><BackspaceIcon /></IconButton> <IconButton color="error" aria-label="remmove winner" component="span" onClick={curryUnsetContestant(props.match.team1Id)}><BackspaceIcon /></IconButton>
} }
{ props.match.team1Id !== null && props.match.winnerId === null && !props.tournament.hasEnded && props.user.isLoggedIn && { props.match.team1Id !== null && props.match.winnerId === null && !props.tournament.hasEnded && props.user.isLoggedIn &&
<IconButton onClick={setWinner(props.match.team1Id)} color="success" aria-label="select winner" component="span"><AddCircleIcon /></IconButton> <IconButton onClick={setWinner(props.match.team1Id)} color="success" aria-label="select winner" component="span"><AddCircleIcon /></IconButton>
} }
{/* { props.match.winnerId && (props.match.team1Id === props.match.winnerId) &&
<EmojiEventsIcon alt="A trohpy" color="gold" />
} */}
</Stack> </Stack>
</li> </li>
<li className="game game-spacer">&nbsp;</li> <li className="game game-spacer">&nbsp;</li>
@ -107,15 +107,15 @@ function Match(props){
<Typography className={`teamName`} sx={{fontSize:'1.5rem', maxWidth:'15vw', overflow:'hidden', wordWrap:'none'}}> <Typography className={`teamName`} sx={{fontSize:'1.5rem', maxWidth:'15vw', overflow:'hidden', wordWrap:'none'}}>
{team2Name} {team2Name}
</Typography> </Typography>
{ props.match.winnerId && (props.match.team2Id === props.match.winnerId) &&
<EmojiEventsIcon alt="A trohpy" color="gold" />
}
{ props.match.team2Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn && { props.match.team2Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn &&
<IconButton color="error" aria-label="remmove winner" component="span" onClick={curryUnsetContestant(props.match.team2Id)}><BackspaceIcon /></IconButton> <IconButton color="error" aria-label="remmove winner" component="span" onClick={curryUnsetContestant(props.match.team2Id)}><BackspaceIcon /></IconButton>
} }
{ props.match.team2Id !== null && props.match.winnerId === null && !props.tournament.hasEnded && props.user.isLoggedIn && { props.match.team2Id !== null && props.match.winnerId === null && !props.tournament.hasEnded && props.user.isLoggedIn &&
<IconButton onClick={setWinner(props.match.team2Id)} color="success" aria-label="select winner" component="span"><AddCircleIcon /></IconButton> <IconButton onClick={setWinner(props.match.team2Id)} color="success" aria-label="select winner" component="span"><AddCircleIcon /></IconButton>
} }
{/* { props.match.winnerId && (props.match.team2Id === props.match.winnerId) &&
<EmojiEventsIcon alt="A trohpy" color="gold" />
} */}
</Stack> </Stack>
</li> </li>
<li className="spacer">&nbsp;</li> <li className="spacer">&nbsp;</li>