import AccountCircleIcon from '@mui/icons-material/AccountCircle'; import PersonIcon from '@mui/icons-material/Person'; import { Box, Button, Divider, IconButton, Popover, Typography, Avatar, styled, MenuItem, TextField } from '@mui/material'; import { useState, useContext } from 'react'; import type { TypographyProps } from '@mui/material'; import type { Locales } from 'i18n/i18n-types'; import type { FC, ChangeEventHandler } from 'react'; import { AuthenticatedContext } from 'contexts/authentication'; import DEflag from 'i18n/DE.svg'; import FRflag from 'i18n/FR.svg'; import GBflag from 'i18n/GB.svg'; import ITflag from 'i18n/IT.svg'; import NLflag from 'i18n/NL.svg'; import NOflag from 'i18n/NO.svg'; import PLflag from 'i18n/PL.svg'; import SVflag from 'i18n/SV.svg'; import TRflag from 'i18n/TR.svg'; import { I18nContext } from 'i18n/i18n-react'; import { loadLocaleAsync } from 'i18n/i18n-util.async'; const ItemTypography = styled(Typography)({ maxWidth: '250px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }); const LayoutAuthMenu: FC = () => { const { me, signOut } = useContext(AuthenticatedContext); const [anchorEl, setAnchorEl] = useState(null); const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const { locale, LL, setLocale } = useContext(I18nContext); const onLocaleSelected: ChangeEventHandler = async ({ target }) => { const loc = target.value as Locales; localStorage.setItem('lang', loc); await loadLocaleAsync(loc); setLocale(loc); }; const handleClose = () => { setAnchorEl(null); }; const open = Boolean(anchorEl); const id = anchorEl ? 'app-menu-popover' : undefined; return ( <>  DE  EN  FR  IT  NL  NO  PL  SV  TR {me.username} {me.admin ? LL.ADMIN() : LL.GUEST()} {LL.USER(2)} ); }; export default LayoutAuthMenu;