From 1d8d6a147489361533e2aaa3ea539d9424af5ba4 Mon Sep 17 00:00:00 2001 From: Luis Felipe Risch <lfr20@inf.ufpr.br> Date: Wed, 30 Sep 2020 12:38:39 -0300 Subject: [PATCH] Nothing changed --- src/Components/MenuList.js | 175 +++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 85 deletions(-) diff --git a/src/Components/MenuList.js b/src/Components/MenuList.js index 796b57b3..44602bed 100644 --- a/src/Components/MenuList.js +++ b/src/Components/MenuList.js @@ -16,7 +16,7 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/ -import React, {useContext} from 'react'; +import React, { useContext } from 'react'; import Button from '@material-ui/core/Button'; import Menu from '@material-ui/core/Menu'; import MenuItem from '@material-ui/core/MenuItem'; @@ -28,15 +28,15 @@ import { Store } from '../Store'; import { Redirect } from "react-router-dom"; import Profile from '../img/default_profile0.png' import styled from 'styled-components' -import {apiDomain} from '../env.js' +import { apiDomain } from '../env.js' const iconStyles = { - fontSize : "xxx-large", + fontSize: "xxx-large", color: "white", backgroundColor: "gray", - borderRadius : "50%", - overflow : "hidden", - border : "2px solid #fff", + borderRadius: "50%", + overflow: "hidden", + border: "2px solid #fff", } const OverrideButton = styled(Button)` @@ -44,87 +44,92 @@ const OverrideButton = styled(Button)` ` export default function MenuList(props) { - const [anchorEl, setAnchorEl] = React.useState(null); - const { state, dispatch } = useContext(Store) - - const handleClick = event => { - setAnchorEl(event.currentTarget); - }; - - const handleClose = () => { - setAnchorEl(null); - }; - - const handleLogout = () => { - localStorage.removeItem('@portalmec/username'); - sessionStorage.removeItem('@portalmec/uid'); - sessionStorage.removeItem('@portalmec/senha'); - dispatch( { - type: 'USER_LOGGED_OUT', - userLoggedOut: !state.userIsLoggedIn, - login: { - username : '', - email : '', - accessToken : '', - client : '' - } - } - ) - } - - return ( - <div > - - <OverrideButton - aria-controls="customized-menu" - aria-haspopup="true" - onMouseEnter={handleClick} - - > - <div style={{borderRadius: "50%", border: "2px solid #fff", background: "#fff", overflow: "hidden", maxWidth : "50px", maxHeight : "50px"}}> - { - state.currentUser.userAvatar == '' || state.currentUser.userAvatar == null ? - ( - - <img src={Profile} alt={'user avatar'} style={{width:"100%", height:"100%", verticalAlign : "middle", marginLeft : "0"}}/> - ): - ( - <img src={apiDomain + state.currentUser.userAvatar} alt={'user avatar'} style={{width:"100%", height:"100%", verticalAlign : "middle", marginLeft : "0"}}/> - ) + const [anchorEl, setAnchorEl] = React.useState(null); + const { state, dispatch } = useContext(Store) + + const handleClick = event => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + + const handleLogout = () => { + localStorage.removeItem('@portalmec/username'); + sessionStorage.removeItem('@portalmec/uid'); + sessionStorage.removeItem('@portalmec/senha'); + dispatch({ + type: 'USER_LOGGED_OUT', + userLoggedOut: !state.userIsLoggedIn, + login: { + username: '', + email: '', + accessToken: '', + client: '' } - </div> - <span style={{fontFamily:"inherit", fontWeight:"400", color:"#666"}}>Minha Ãrea </span> <KeyboardArrowDownIcon/> - </OverrideButton> - - <Menu - anchorEl={anchorEl} - open={Boolean(anchorEl)} - onClose={handleClose} - elevation={0} - getContentAnchorEl={null} - anchorOrigin={{ - vertical: 'bottom', - horizontal: 'center', - }} - transformOrigin={{ - vertical: 'top', - horizontal: 'center', - }}> - - { - props.items.map((item)=> - <Link to={{ - pathname : item.href, - state : item.value - }} style={{textDecoration:"none"}} key={item.value}><MenuItem style= {{fontSize:"14px", padding:"5px 20px", color:"#666"}}>{item.name}</MenuItem></Link> - ) } - <StyledButtonSair onClick={handleLogout}> <StyledMenuItem disableGutters={true}>Sair<StyledExitToAppIcon/></StyledMenuItem></StyledButtonSair> - + ) + } - </Menu> - </div> - ); + return ( + <div > + + <OverrideButton + aria-controls="customized-menu" + aria-haspopup="true" + onMouseEnter={handleClick} + + > + <div style={{ borderRadius: "50%", border: "2px solid #fff", background: "#fff", overflow: "hidden", maxWidth: "50px", maxHeight: "50px" }}> + { + state.currentUser.userAvatar == '' || state.currentUser.userAvatar == null ? + ( + + <img src={Profile} alt={'user avatar'} style={{ width: "100%", height: "100%", verticalAlign: "middle", marginLeft: "0" }} /> + ) : + ( + <img src={apiDomain + state.currentUser.userAvatar} alt={'user avatar'} style={{ width: "100%", height: "100%", verticalAlign: "middle", marginLeft: "0" }} /> + ) + } + </div> + <span style={{ fontFamily: "inherit", fontWeight: "400", color: "#666" }}>Minha Ãrea </span> <KeyboardArrowDownIcon /> + </OverrideButton> + + <Menu + anchorEl={anchorEl} + open={Boolean(anchorEl)} + onClose={handleClose} + elevation={0} + getContentAnchorEl={null} + anchorOrigin={{ + vertical: 'bottom', + horizontal: 'center', + }} + transformOrigin={{ + vertical: 'top', + horizontal: 'center', + }}> + + { + props.items.map((item) => + <Link to={{ + pathname: item.href, + state: item.value + }} + style={{ textDecoration: "none" }} key={item.value}> + <MenuItem style={{ fontSize: "14px", padding: "5px 20px", color: "#666" }}> + {item.name} + </MenuItem> + </Link> + ) + } + <StyledButtonSair onClick={handleLogout}> <StyledMenuItem disableGutters={true}>Sair<StyledExitToAppIcon /></StyledMenuItem></StyledButtonSair> + + + </Menu> + </div> + ); } const StyledButtonSair = styled(Button)` @@ -142,7 +147,7 @@ const StyledButtonSair = styled(Button)` } ` -const StyledExitToAppIcon = styled(ExitToAppIcon) ` +const StyledExitToAppIcon = styled(ExitToAppIcon)` fontSize : 24px; color : rgb(162,165,165); align : right; -- GitLab