Newer
Older

Lucas Eduardo Schoenfelder
committed
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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/>.*/

Lucas Eduardo Schoenfelder
committed
import styled from 'styled-components'
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import ReportIcon from '@material-ui/icons/Error';
import Button from '@material-ui/core/Button';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import ReportModal from './ReportModal.js'

Lucas Eduardo Schoenfelder
committed
export default function ReportButton(props) {
const { state } = useContext(Store)

Lucas Eduardo Schoenfelder
committed
/*Menu control variables-----------------------------*/
const [anchorEl, setAnchorEl] = React.useState(null);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
/*---------------------------------------------------*/
/*modal variables------------------------------------*/
const [reportModal, toggleReportModal] = useState(false)

Lucas Eduardo Schoenfelder
committed
const [loginModal, toggleLoginModal] = useState(false)
const handleModal = () => {
if (state.currentUser.id) {
toggleReportModal(!reportModal)
}
else {
toggleLoginModal(true)
}
}
/*---------------------------------------------------*/
return (
<>
<ReportModal contrast={state.contrast} open={reportModal} handleClose={() => handleModal()}
form="user" complainableId={props.complainableId}
complainableType={props.complainableType}

Lucas Eduardo Schoenfelder
committed
loginModal &&
<LoginModal open={loginModal} handleClose={() => {toggleLoginModal(false)}}/>
*/}
<Button onClick={handleClick}>
<MoreVertIcon style={state.contrast === "" ? { color: "#666" } : { color: "white" }} />
</Button>
<StyledMenu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleClose}
style={{ borderRadius: "0" }}
>
<MenuItem onClick={() => { handleModal() }} style={state.contrast === "" ? { color: "#666", backgroundColor: "black" } : { color: "white", backgroundColor: "black" }}>
<ReportIcon />
<span style={state.contrast === "" ? { paddingLeft: "3px" } : { paddingLeft: "3px", color: "yellow", textDecoration: "underline" }}>Reportar</span>
</MenuItem>
</StyledMenu>