Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

257 app ocultar iconos de barra de navegación en login y register #272

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 58 additions & 38 deletions webapp/src/components/nav/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import AccountCircle from "@mui/icons-material/AccountCircle";
import NightlightIcon from "@mui/icons-material/Nightlight";
import TranslateIcon from "@mui/icons-material/Translate";
import SettingsIcon from "@mui/icons-material/Settings";
import AccountCircleIcon from '@mui/icons-material/AccountCircle';
import HistoryIcon from '@mui/icons-material/History';
import GroupsIcon from '@mui/icons-material/Groups';
import i18n from "../../i18n";


Expand Down Expand Up @@ -149,6 +152,8 @@ export const Nav = () => {
navigate("/settings");
};

const hasToken = localStorage.getItem('token') !== null;

return (
<Box sx={{ flexGrow: 1 }}>
<AppBar position="static">
Expand Down Expand Up @@ -205,56 +210,71 @@ export const Nav = () => {
onClick={spanish}
>
<span className="fi fi-es mr-1"></span>
Español
{ t('Nav.spanish') }
</MenuItem>
<MenuItem
selected={i18n.language === "en" ? true : false}
onClick={english}
>
<span className="fi fi-gb mr-1"></span>
Inglés
{ t('Nav.english') }
</MenuItem>
</Menu>

{/** Settings Icon */}
<IconButton onClick={openSettings} size="large" color="inherit" data-testid="go-settings">
<SettingsIcon style={{ color: color }} />
</IconButton>
{
hasToken && (
<IconButton onClick={openSettings} size="large" color="inherit" data-testid="go-settings">
<SettingsIcon style={{ color: color }} />
</IconButton>
)
}

{/* Botón de cuenta */}
<IconButton
size="large"
aria-label="account of current user"
aria-controls="account-appbar"
aria-haspopup="true"
onClick={handleMenuAccountOpen}
color="inherit"
data-testid="open-account-menu"
>
<AccountCircle style={{ color: color }} />
</IconButton>

<Menu
id="account-appbar"
open={openMenuAccount}
onClose={handleMenuAccountClose}
anchorEl={userAnchor}
>

<MenuItem onClick={profile} data-testid="go-profile">Perfil</MenuItem>
<MenuItem onClick={history} data-testid="go-history">Historial</MenuItem>
<MenuItem onClick={friends} data-testid="go-friends">Amigos</MenuItem>

</Menu>

<IconButton
size="large"
color="inherit"
onClick={logout}
data-testid="logout"
>
<LogoutIcon style={{ color: color }} />
</IconButton>
{
hasToken && (
<>
<IconButton
size="large"
aria-label="account of current user"
aria-controls="account-appbar"
aria-haspopup="true"
onClick={handleMenuAccountOpen}
color="inherit"
data-testid="open-account-menu"
>
<AccountCircle style={{ color: color }} />
</IconButton>

<Menu
id="account-appbar"
open={openMenuAccount}
onClose={handleMenuAccountClose}
anchorEl={userAnchor}
>

<MenuItem onClick={profile} data-testid="go-profile"><AccountCircleIcon className="mr-1" />{ t('Nav.profile') }</MenuItem>
<MenuItem onClick={history} data-testid="go-history"><HistoryIcon className="mr-1"/>{ t('Nav.history') }</MenuItem>
<MenuItem onClick={friends} data-testid="go-friends"><GroupsIcon className="mr-1"/>{ t('Nav.friends') }</MenuItem>

</Menu>
</>
)
}

{ /* Logout */ }
{
hasToken && (
<IconButton
size="large"
color="inherit"
onClick={logout}
data-testid="logout"
>
<LogoutIcon style={{ color: color }} />
</IconButton>
)
}
</Toolbar>
</AppBar>
</Box>
Expand Down
10 changes: 10 additions & 0 deletions webapp/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ i18n
alertText: 'Your game will end.',
alertConfirm: 'Yes, go out',
alertCancel: 'No, continue playing',
profile: 'Profile',
history: 'History',
friends: 'Friends',
spanish: 'Spanish',
english: 'English'
},
Home: {
home: 'Home',
Expand Down Expand Up @@ -107,6 +112,11 @@ i18n
alertText: 'Terminará tu partida.',
alertConfirm: 'Sí, salir',
alertCancel: 'No, continuar jugando',
profile: 'Perfil',
history: 'Historial',
friends: 'Amigos',
spanish: 'Español',
english: 'Inglés'
},
Home: {
home: 'Inicio',
Expand Down