diff --git a/webapp/public/british-flag.png b/webapp/public/british-flag.png deleted file mode 100644 index 96703563..00000000 Binary files a/webapp/public/british-flag.png and /dev/null differ diff --git a/webapp/public/spanish-flag.png b/webapp/public/spanish-flag.png deleted file mode 100644 index bb809d40..00000000 Binary files a/webapp/public/spanish-flag.png and /dev/null differ diff --git a/webapp/src/common/Nav.tsx b/webapp/src/common/Nav.tsx index 977e158a..0f054825 100644 --- a/webapp/src/common/Nav.tsx +++ b/webapp/src/common/Nav.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import './nav.scss'; import { useTranslation } from 'react-i18next'; -import { AppBar, Container, Toolbar, Grid, Stack, Button, Menu, MenuItem, Switch } from "@mui/material"; +import { AppBar, Container, Toolbar, Grid, Stack, Button, Menu, MenuItem } from "@mui/material"; import { useNavigate } from "react-router-dom"; const NavBar: React.FC<{}> = () => @@ -12,32 +12,41 @@ const NavBar: React.FC<{}> = () => const navigate = useNavigate(); const value:string= JSON.stringify(localStorage.getItem("isAuthenticated")).replace("\"","").replace("\"",""); const user = JSON.stringify(localStorage.getItem("username")).replace("\"", "").replace("\"", ""); - const [anchorEl, setAnchorEl] = useState(null); - const [open, setOpen] = useState(false); - const [chevronRotated, setChevronRotated] = useState(true); + const [profileAnchorEl, setProfileAnchorEl] = useState(null); + const [languageAnchorEl, setLanguageAnchorEl] = useState(null); + const [profileOpen, setProfileOpen] = useState(false); + const [languageOpen, setLanguageOpen] = useState(false); + const [profileChevronRotated, setProfileChevronRotated] = useState(false); + const [languageChevronRotated, setLanguageChevronRotated] = useState(false); + const [selectedLanguage, setSelectedLanguage] = useState(localStorage.getItem("lang")); // Default language is English - const handleClick = (event: React.MouseEvent | React.MouseEvent) => { - setAnchorEl(event.currentTarget); - setOpen(!open); - setChevronRotated(!chevronRotated); + + const handleProfileClick = (event: React.MouseEvent | React.MouseEvent) => { + setProfileAnchorEl(event.currentTarget); + setProfileOpen(!profileOpen); + setProfileChevronRotated(!profileChevronRotated); + }; + + const handleLanguageClick = (event: React.MouseEvent | React.MouseEvent) => { + setLanguageAnchorEl(event.currentTarget); + setLanguageOpen(!languageOpen); + setLanguageChevronRotated(!languageChevronRotated); }; const handleClose = () => { - setAnchorEl(null); - setOpen(false); - setChevronRotated(false); + setProfileAnchorEl(null); + setLanguageAnchorEl(null); + setProfileOpen(false); + setLanguageOpen(false); + setProfileChevronRotated(false); + setLanguageChevronRotated(false); }; - const handleSwitch = () => { - const language = localStorage.getItem("lang"); - if(language === "es"){ - localStorage.setItem("lang", "en"); - i18n.changeLanguage("en"); - } - else{ - localStorage.setItem("lang", "es"); - i18n.changeLanguage("es"); - } + const handleLanguageSelect = (lang: string) => { + setSelectedLanguage(lang); + localStorage.setItem("lang", lang); + i18n.changeLanguage(lang); + handleClose(); }; if(value === "false"){ @@ -98,18 +107,20 @@ const NavBar: React.FC<{}> = () => + handleClose()} - anchorEl={anchorEl} + anchorEl={profileAnchorEl} anchorOrigin={{ vertical: 'bottom', - horizontal: 'right', + horizontal: 180, }} sx={{ marginTop: '5px' }} > @@ -159,23 +197,26 @@ const NavBar: React.FC<{}> = () => > {t('nav_logout')} - - British flag - {localStorage.getItem("lang") === 'en' && ( - - )} - {localStorage.getItem("lang") === 'es' && ( - - )} - Spanish flag + + + + handleClose()} + anchorEl={languageAnchorEl} + anchorOrigin={{ + vertical: 'bottom', + horizontal: -5, + }} + sx={{ marginTop: '5px' }} + > + handleLanguageSelect("en")}> + English + + handleLanguageSelect("es")}> + EspaƱol diff --git a/webapp/src/common/nav.scss b/webapp/src/common/nav.scss index 9669fa7e..45b46d85 100644 --- a/webapp/src/common/nav.scss +++ b/webapp/src/common/nav.scss @@ -43,8 +43,10 @@ } .chevron{ - margin-top: 1px; transition: transform 0.1s ease; + &--menu{ + margin-top: 1px; + } } .chevron--rotated{