Newer
Older
/*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/>.*/
import { Button } from '@material-ui/core';
import Modal from '@material-ui/core/Modal';
import Backdrop from '@material-ui/core/Backdrop';
import Fade from '@material-ui/core/Fade';
import styled from 'styled-components'
import CloseModalButton from './CloseModalButton'
const handleCancel = () => {
props.handleClose()
props.cancel()
}
const transformReportCriteria = (criteria) => {
let newArr = []
criteria.map((criterium) =>
newArr.push({ "question_id": criterium.id, "accepted": criterium.accepted })
)
return newArr
}
props.finalizeCuratorshipFlow()
}
const handleConfirmation = () => {
const url = `/submissions/${props.recursoId}/answer`
"submission": {
"justification": props.justificativa,
"answers": transformReportCriteria(props.reportCriteria)
postRequest(
url,
payload,
handleSuccess,
(error) => {
props.handleErrorAprove()
}
)
}
return (
<StyledModal
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
open={props.open}
centered="true"
onClose={props.handleClose}
closeAfterTransition
BackdropComponent={Backdrop}
BackdropProps={{
timeout: 500,
}}
>
<Fade in={props.open}>
<Container contrast={props.contrast} recusado={!props.aceito}>
<h2>Recurso a ser {props.aceito ? 'aprovado' : 'recusado'}</h2>
</Header>
<Content>
{
props.aceito ?
(
<p>Este recurso será publicado na plataforma. Você confirma essa avaliação?
</p>
)
:
(
<>
<p>Agradecemos a sua contribuição. Você avaliou que o recurso não está em conformidade com o(s) seguinte(s) critério(s):
{
props.reportCriteria.filter((criterium) => criterium.accepted === false).map((criterium) =>
<p key={criterium.id} className="reason-offensive">{criterium.text}</p>
)
}
<p>Você confirma essa avaliação? Ao confirmar, o recurso não será publicado na plataforma.</p>
</>
)
<ButtonEnviarAvaliar contrast={props.contrast} onClick={() => { handleConfirmation() }}>SIM, CONFIRMAR</ButtonEnviarAvaliar>
<GreyButton contrast={props.contrast} onClick={handleCancel}>NÃO, ALTERAR AVALIAÇÃO</GreyButton>
</Content>
</Container>
</Fade>
</StyledModal>
)
}
const Content = styled.div`
padding : 30px;
overflow : visible;
max-width : 100%;
font-size : 16px;
text-align : start;
.reason-offensive {
font-weight : 700;
}
p {
margin : 0 0 10px;
}
`
const Header = styled.div`
display : flex;
flex-direction : row;
align-items : center;
max-height : none;
justify-content : space-between;
h2 {
font-size : 30px;
margin-top : 20px;
margin-bottom : 10px;
font-weight : lighter;
}
`
const StyledModal = styled(Modal)`
.djXaxP{
margin : 0 !important;
}
display : flex;
align-items: center;
justify-content : center;
text-align : center;
padding : 10px !important;
max-width : none;
max-height : none;
`
const Container = styled.div`
box-sizing : border-box;
box-shadow : 0 7px 8px -4px rgba(0,0,0,.2),0 13px 19px 2px rgba(0,0,0,.14),0 5px 24px 4px rgba(0,0,0,.12);
background-color : ${props => props.contrast === "" ? "white" : "black"} !important;
color : ${props => props.contrast === "" ? "#666" : "white"} !important;
align : center;
display : flex;
flex-direction : column;
min-width : 240px;
position : relative;
border-radius : 4px;
max-width : 100%;
border: ${props => props.contrast === "" ? "" : "1px solid white"} !important;
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
max-height : ${props => props.recusado ? 'none' : '370px'};
@media screen and (max-width : 699px) {
overflow : ${props => props.recusado ? 'scroll' : 'visible'};
width : 100%;
height : 100%;
}
p {
margin : 0 0 10px;
}
`
const ButtonsDiv = styled.div`
display : flex;
max-width : 100%;
text-align : center;
align-items : center;
justify-content : center;
padding-top : 20px;
@media screen and (min-width : 990px) {
flex-direction : row;
}
@media screen and (max-width : 989px) {
flex-direction : column;
}
`
const GreyButton = styled(Button)`
&:hover {
background-color : ${props => props.contrast === "" ? "rgba(158,158,158,0.2)" : ""} !important;
}
max-height : 36px !important;
background-color : transparent !important;
color: ${props => props.contrast === "" ? "#666" : "yellow"} !important;
text-decoration : ${props => props.contrast === "" ? "none" : "underline"} !important;
outline : none !important;
text-align : center !important;
font-weight : 600 !important;
.MuiButton-label {
padding-left : 16px !important;
padding-right : 16px !important;
}
@media screen and (max-width : 989px) {
margin-top : 10px !important;
}
`
const ButtonEnviarAvaliar = styled(Button)`
color : ${props => props.contrast === "" ? `rgba(255,255,255,0.87)` : `yellow`} !important;
font-weight : 600 !important;
background-color : ${props => props.contrast === "" ? "#ff7f00" : "black"} !important;
text-decoration: ${props => props.contrast === "" ? "none" : "underline"} !important;
border: ${props => props.contrast === "" ? "" : "1px solid white"} !important;
margin-left : 8px !important;
margin-right : 8px !important;
.MuiButton-label {
padding-left : 16px !important;
padding-right : 16px !important;
}
`