From c20cea953d58e7519fffbc85072a2f41289119b1 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sat, 23 Apr 2022 15:06:23 +0200 Subject: [PATCH] =?UTF-8?q?kl=C3=A6bb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/src/FrontPage.js | 1 + src/client/src/ProfilePage.js | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 6321fea..2c027fe 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -219,6 +219,7 @@ class LoginManager { } console.log(data); this.user = data.data; + return this.user; }) .catch((err) => console.log(err.message)); } diff --git a/src/client/src/ProfilePage.js b/src/client/src/ProfilePage.js index 39bdd3d..5ca3dcd 100644 --- a/src/client/src/ProfilePage.js +++ b/src/client/src/ProfilePage.js @@ -5,16 +5,17 @@ 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) { - if (!props.login) { - return

Something went very wrong

- } + const [loggedIn, setLoggedIn] = React.useState(props.login.isLoggedIn()); + React.useEffect(() => { + setLoggedIn(props.login.isLoggedIn()); + }, [props.login]); + let user = props.login.user; - console.log(props.login); return (<> - {props.login.isLoggedIn() ? <> + {loggedIn ? <>

Your profile