Previous commit extended

This commit is contained in:
Felix Albrigtsen 2022-04-24 13:10:46 +02:00
parent 2c06a8adb2
commit 4f229ff642
5 changed files with 36 additions and 21 deletions

View File

@ -2,7 +2,7 @@ import * as React from "react";
import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom";
import Appbar from "./components/AsuraBar"; import Appbar from "./components/AsuraBar";
import ErrorSnackbar from "./components/ErrorSnackbar"; import ErrorSnackbar from "./components/ErrorSnackbar";
import LoginPage from "./LoginPage";
import {Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography} from '@mui/material'; import {Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography} from '@mui/material';
import AddCircleIcon from '@mui/icons-material/AddCircle'; import AddCircleIcon from '@mui/icons-material/AddCircle';
import DeleteIcon from '@mui/icons-material/Delete'; import DeleteIcon from '@mui/icons-material/Delete';
@ -129,6 +129,17 @@ export default function Users(props) {
getUsers() getUsers()
}, []); }, []);
if (!props.user.isLoggedIn) { return <LoginPage user={props.user} />; }
if (!props.user.isManager) {
return (<>
<Appbar user={props.user} pageTitle="Admins" />
<Paper sx={{minHeight: "30vh", width:"90vw", margin:"10px auto", padding: "25px"}} component={Stack} direction="column" justifycontent="center">
<div align="center">
<Typography variant="h4">You do not have permission to view this page. If you believe this is incorrect, please contact a manager.</Typography>
</div>
</Paper>
</>);
}
return ( return (
<> <>
<Appbar user={props.user} pageTitle="Admins" /> <Appbar user={props.user} pageTitle="Admins" />

View File

@ -15,11 +15,11 @@ export default function LoginPage(props) {
return ( return (
<> <>
<Appbar user={props.user} pageTitle="Login" /> <Appbar user={props.user} pageTitle="Login" />
<Paper sx={{width: "70vw", margin: "1.5% auto"}} component={Stack} direction="column" justifyContent="center" alignItems="center"> <Paper sx={{width: "70vw", margin: "1.5% auto", padding: "25px"}} component={Stack} direction="column" justifyContent="center" alignItems="center">
<Stack direction="column" paddingTop={'0.5%'} alignItems={'center'} textAlign={"center"} >
<Typography variant="h4" component="h4"> <Typography variant="h4" component="h4">
You must be logged in to access administrator features. You must be logged in to access administrator features.
</Typography> </Typography>
<Stack direction="column" paddingTop={'0.5%'} alignItems={'center'}>
<a href={process.env.REACT_APP_LOGIN_URL}> <a href={process.env.REACT_APP_LOGIN_URL}>
<img src="/btn_google_signing_dark.png" alt="Sign in with google" /> <img src="/btn_google_signing_dark.png" alt="Sign in with google" />
</a> </a>

View File

@ -2,7 +2,7 @@ import * as React from "react";
import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom";
import Appbar from "./components/AsuraBar"; import Appbar from "./components/AsuraBar";
import ErrorSnackbar from "./components/ErrorSnackbar"; import ErrorSnackbar from "./components/ErrorSnackbar";
import LoginPage from "./LoginPage";
import { Button, TextField, Stack, InputLabel, Select, Container, Slider, Paper, Box, Grid, Typography } from '@mui/material'; import { Button, TextField, Stack, InputLabel, Select, Container, Slider, Paper, Box, Grid, Typography } from '@mui/material';
import DateTimePicker from '@mui/lab/DateTimePicker'; import DateTimePicker from '@mui/lab/DateTimePicker';
import AdapterDateFns from '@mui/lab/AdapterDateFns'; import AdapterDateFns from '@mui/lab/AdapterDateFns';
@ -168,6 +168,8 @@ export default function TournamentCreator(props) {
setOpenError(true); setOpenError(true);
} }
if (!props.user.isLoggedIn) { return <LoginPage user={props.user} />; }
return ( return (
<> <>
<Appbar user={props.user} pageTitle="New tournament" /> <Appbar user={props.user} pageTitle="New tournament" />

View File

@ -9,7 +9,7 @@ function MatchHistory() {
); );
} }
export default function TournamentMatches() { export default function TournamentMatches(props) {
return ( return (
<> <>
<Appbar user={props.user} /> <Appbar user={props.user} />

View File

@ -9,7 +9,7 @@ import LogoutIcon from '@mui/icons-material/Logout';
import LoginIcon from '@mui/icons-material/Login'; import LoginIcon from '@mui/icons-material/Login';
import logo from "./../Asura2222.png"; import logo from "./../Asura2222.png";
function LoggedInMenu() { function LoggedInMenu(props) {
const [anchorEl, setAnchorEl] = React.useState(null); const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const handleClick = (event) => { const handleClick = (event) => {
@ -32,7 +32,9 @@ function LoggedInMenu() {
<Link to="/" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<AccountCircleIcon />}>Profile</Button></MenuItem></Link> <Link to="/" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<AccountCircleIcon />}>Profile</Button></MenuItem></Link>
<Link to="/history" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<HistoryIcon />}>History</Button></MenuItem></Link> <Link to="/history" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<HistoryIcon />}>History</Button></MenuItem></Link>
<Link to="/api/logout" style={{color:"black"}}><MenuItem onClick={logout}><Button endIcon={<LogoutIcon />} >Logout</Button></MenuItem></Link> <Link to="/api/logout" style={{color:"black"}}><MenuItem onClick={logout}><Button endIcon={<LogoutIcon />} >Logout</Button></MenuItem></Link>
{ props.user.isManager &&
<Link to="/admins" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<EditIcon />} >Admins</Button></MenuItem></Link> <Link to="/admins" style={{color:"black"}}><MenuItem onClick={handleClose}><Button endIcon={<EditIcon />} >Admins</Button></MenuItem></Link>
}
</Menu> </Menu>
</> </>
); );
@ -83,7 +85,7 @@ export default function Appbar(props) {
</Grid> </Grid>
{ props.pageTitle !== "Login" ? { props.pageTitle !== "Login" ?
<Grid item xs={2}> <Grid item xs={2}>
{ props.user.isLogggedIn ? <LoggedInMenu /> : <NotLoggedInButton /> } { props.user.isLoggedIn ? <LoggedInMenu user={props.user} /> : <NotLoggedInButton /> }
</Grid> : </Grid> :
<Grid item xs={2}> <Grid item xs={2}>
</Grid> </Grid>