From 4ca4664b2d0680958545e4e04b6d619f8b526789 Mon Sep 17 00:00:00 2001 From: Gemma Date: Wed, 14 Feb 2024 10:54:08 +0100 Subject: [PATCH] userName saved when refreshing --- frontend/src/components/Datasets/ResultsDatasets.css | 8 ++++---- frontend/src/components/NavBar/Navbar.css | 2 +- frontend/src/components/NavBar/Navbar.js | 9 +++++++-- frontend/src/components/SignIn/LoggedIn.js | 5 ++++- frontend/src/components/SignIn/SignInFormNoLS.js | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/Datasets/ResultsDatasets.css b/frontend/src/components/Datasets/ResultsDatasets.css index acaca07..81b66f9 100644 --- a/frontend/src/components/Datasets/ResultsDatasets.css +++ b/frontend/src/components/Datasets/ResultsDatasets.css @@ -226,11 +226,11 @@ p a { .resultsRecord { display: flex; flex-direction: row; - height: 140%; flex-wrap: wrap; justify-content: center; align-content: center; - padding-bottom: 10px; + padding-bottom: 60px; + margin-top: 60px; } @media (max-width: 860px) { @@ -258,8 +258,8 @@ p a { justify-content: center; align-content: center; width: 100vw; - padding-bottom: 10px; - height: 160%; + margin-top: 60px; + padding-bottom: 60px; } .tittle4 { diff --git a/frontend/src/components/NavBar/Navbar.css b/frontend/src/components/NavBar/Navbar.css index 0756a3f..978b138 100644 --- a/frontend/src/components/NavBar/Navbar.css +++ b/frontend/src/components/NavBar/Navbar.css @@ -273,7 +273,7 @@ .Members3:hover ~ .animation { width: 150px; - right: 349px; + right: 20.5%; background-color: #4961b8; } diff --git a/frontend/src/components/NavBar/Navbar.js b/frontend/src/components/NavBar/Navbar.js index 799a07b..3bd7435 100644 --- a/frontend/src/components/NavBar/Navbar.js +++ b/frontend/src/components/NavBar/Navbar.js @@ -18,13 +18,18 @@ function Navbar () { logOutUser, authenticateUser, getStoredToken, - userNameToShare + userNameToShare, + setUserNameToShare } = useContext(AuthContext) const auth = useAuth() const navigate = useNavigate() useEffect(() => { + let user = localStorage.getItem('userName') + if (user !== ''){ + setUserNameToShare(user) + } authenticateUser() let token = getStoredToken() let isAuthenticated = false @@ -39,7 +44,7 @@ function Navbar () { } else { setIsLoggedIn(false) } - }, []) + }, [userNameToShare]) const handleHelpModal1 = () => { setIsOpenModal1(true) diff --git a/frontend/src/components/SignIn/LoggedIn.js b/frontend/src/components/SignIn/LoggedIn.js index a5e248a..2cd4075 100644 --- a/frontend/src/components/SignIn/LoggedIn.js +++ b/frontend/src/components/SignIn/LoggedIn.js @@ -10,7 +10,10 @@ const LoggedIn = () => { if (auth && auth.userData) { setIsLoggedIn(true) - setUserNameToShare(auth.userData.profile.name) + + setUserNameToShare( + localStorage.setItem('userName', auth.userData.profile.name) + ) return (
diff --git a/frontend/src/components/SignIn/SignInFormNoLS.js b/frontend/src/components/SignIn/SignInFormNoLS.js index 413a5db..0975941 100644 --- a/frontend/src/components/SignIn/SignInFormNoLS.js +++ b/frontend/src/components/SignIn/SignInFormNoLS.js @@ -12,6 +12,7 @@ export default function SignInFormNoLS () { const [error, setError] = useState('') const navigate = useNavigate() + const { storeToken, setIsLoggedIn, @@ -77,7 +78,7 @@ export default function SignInFormNoLS () { if (readableResponse.access_token) { navigate('/') setIsLoggedIn(true) - setUserNameToShare(userName) + setUserNameToShare(localStorage.setItem('userName', userName)) } else { setError( 'User not found. Please check the username and the password and retry'