diff --git a/src/client/src/AdminsOverview.js b/src/client/src/AdminsOverview.js index a38ae2d..112e0d0 100644 --- a/src/client/src/AdminsOverview.js +++ b/src/client/src/AdminsOverview.js @@ -131,7 +131,7 @@ export default function Users(props) { return ( <> - +
diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 445d84f..a2e5f32 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -8,7 +8,7 @@ import TournamentHistory from "./TournamentHistory"; import TournamentTeams from "./TournamentTeams"; import LoginPage from "./LoginPage"; import ProfilePage from "./ProfilePage"; -import AppBar from './components/AsuraBar'; +import Appbar from './components/AsuraBar'; import SuccessSnackbar from "./components/SuccessSnackbar"; import ErrorSnackbar from "./components/ErrorSnackbar"; import AdminsOverview from "./AdminsOverview"; @@ -20,8 +20,6 @@ import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp import EditIcon from '@mui/icons-material/Edit'; import EmojiEventsIcon from '@mui/icons-material/EmojiEvents'; -let isLoggedIn = true; - function CreateButton(props) { return ( @@ -121,7 +119,7 @@ function TournamentListItem(props) { - { isLoggedIn ? + { props.user.isLoggedIn ? @@ -144,7 +142,7 @@ function TournamentListItem(props) { ); } -function TournamentList() { +function TournamentList(props) { let [tournamentList, setTournamentList] = React.useState([]); React.useEffect(() => { @@ -174,24 +172,24 @@ function TournamentList() { return <> - {tournamentList && tournamentList.map((tournamentObject) => )} + {tournamentList && tournamentList.map((tournamentObject) => )} ; } -function Home() { +function Home(props) { return ( <> - + {/* */} Tournaments - { isLoggedIn ? + { props.user.isLoggedIn ? : null } - + Finished tournaments are moved to the history-page @@ -241,24 +239,18 @@ export default function App() { .then(res => res.json()) .then(data => { if (data.status !== "OK") { - setUser({ - isManager: false, - isLoggedIn: false - }); - console.error(data.data); + setUser({ isManager: false, isLoggedIn: false }); + console.log(data.data); return; } - console.log(data); let u = data.data; u.isLoggedIn = true; + console.log("User is logged in") setUser(u); }) .catch((err) => { - console.log(err.message); - setUser({ - isManager: false, - isLoggedIn: false - }); + showError(err.message); + setUser({ isManager: false, isLoggedIn: false }); }); } @@ -286,15 +278,15 @@ export default function App() { - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> diff --git a/src/client/src/LoginPage.js b/src/client/src/LoginPage.js index 63599ce..8ee614a 100644 --- a/src/client/src/LoginPage.js +++ b/src/client/src/LoginPage.js @@ -1,14 +1,14 @@ import * as React from "react"; 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 {Button, Textfield, Stack, InputLabel, Paper, Typography} from '@mui/material'; -export default function LoginPage() { +export default function LoginPage(props) { return ( <> - + Sign in with google diff --git a/src/client/src/ProfilePage.js b/src/client/src/ProfilePage.js index 635f62f..ea63454 100644 --- a/src/client/src/ProfilePage.js +++ b/src/client/src/ProfilePage.js @@ -1,13 +1,13 @@ import * as React from "react"; 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 { Button, TextField, Stack, InputLabel, Select, Container, Slider, Paper, Box, Grid, Typography } from '@mui/material'; export default function ProfilePage(props) { let user = props.user; return (<> - + {user.isLoggedIn ? <> diff --git a/src/client/src/TournamentCreator.js b/src/client/src/TournamentCreator.js index aba7cd4..eaefb4b 100644 --- a/src/client/src/TournamentCreator.js +++ b/src/client/src/TournamentCreator.js @@ -170,7 +170,7 @@ export default function TournamentCreator(props) { return ( <> - + diff --git a/src/client/src/TournamentManager.js b/src/client/src/TournamentManager.js index 694e0e6..be86e4c 100644 --- a/src/client/src/TournamentManager.js +++ b/src/client/src/TournamentManager.js @@ -222,7 +222,7 @@ export default function TournamentManager(props) { showSuccess = props.showSuccess; return ( <> - + diff --git a/src/client/src/TournamentMatches.js b/src/client/src/TournamentMatches.js index 44772c8..8311309 100644 --- a/src/client/src/TournamentMatches.js +++ b/src/client/src/TournamentMatches.js @@ -1,6 +1,6 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; -import Appbar from './components/Appbar'; +import Appbar from './components/AsuraBar'; function MatchHistory() { @@ -12,7 +12,7 @@ function MatchHistory() { export default function TournamentMatches() { return ( <> - + ); diff --git a/src/client/src/TournamentOverview.js b/src/client/src/TournamentOverview.js index f7fd094..558d56d 100644 --- a/src/client/src/TournamentOverview.js +++ b/src/client/src/TournamentOverview.js @@ -10,7 +10,6 @@ import DoDisturbIcon from '@mui/icons-material/DoDisturb'; import BackspaceIcon from '@mui/icons-material/Backspace'; import AddCircleIcon from '@mui/icons-material/AddCircle'; -let isLoggedIn = true; function showError(error) { alert("Something went wrong. \n" + error); @@ -208,8 +207,8 @@ export default function TournamentOverview(props) { return ( <> - - { isLoggedIn && !tournament.hasEnded ? + + { props.user.isLoggedIn && !tournament.hasEnded ? : null } diff --git a/src/client/src/TournamentTeams.js b/src/client/src/TournamentTeams.js index 90b1487..ea8b13b 100644 --- a/src/client/src/TournamentTeams.js +++ b/src/client/src/TournamentTeams.js @@ -205,7 +205,7 @@ export default function TournamentTeams(props) { return ( <> - +
diff --git a/src/client/src/components/AsuraBar.js b/src/client/src/components/AsuraBar.js index d1384a2..9c84d42 100644 --- a/src/client/src/components/AsuraBar.js +++ b/src/client/src/components/AsuraBar.js @@ -9,8 +9,6 @@ import LogoutIcon from '@mui/icons-material/Logout'; import LoginIcon from '@mui/icons-material/Login'; import logo from "./../Asura2222.png"; -var isLoggedIn = false; // props.isLoggedIn; - function LoggedInMenu() { const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); @@ -22,8 +20,6 @@ function LoggedInMenu() { }; const logout = () => { - console.log("Logged out"); - isLoggedIn = false; setAnchorEl(null); } @@ -35,7 +31,7 @@ function LoggedInMenu() { - + @@ -44,10 +40,7 @@ function LoggedInMenu() { function NotLoggedInButton() { - const login = () => { - console.log("Logged in"); - isLoggedIn = true; } return ( @@ -88,7 +81,7 @@ export default function Appbar(props) { { props.pageTitle !== "Sign in" ? - { isLoggedIn ? : } + { props.user.isLogggedIn ? : } :