diff --git a/package-lock.json b/package-lock.json index dff899627684dc4a894a7415e6cd2e0e65709081..895b0bb9210a61f22b4f30d0cd4ac7a5514222c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2038,6 +2038,14 @@ } } }, + "@types/react-recaptcha": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/react-recaptcha/-/react-recaptcha-2.3.3.tgz", + "integrity": "sha512-1IdhJxBbPN+QL/eARSl/qwV2+03kwewJmZ43CWJJoGVZd4S4wGiascCl1HVe8PRtNPzXDqAi+nXIufvEDIsAPg==", + "requires": { + "@types/react": "*" + } + }, "@types/react-transition-group": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.0.tgz", diff --git a/package.json b/package.json index 6c44b79445f56fdbb0e65b8f636b81ecd597c08e..47016670d92f4ba048442640ddddd3f1b4ca8e07 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@material-ui/lab": "^4.0.0-alpha.57", "@material-ui/styles": "^4.11.2", "@syncfusion/ej2-react-inputs": "^18.3.52", + "@types/react-recaptcha": "^2.3.3", "antd": "^4.13.1", "axios": "^0.21.1", "base64-img": "^1.0.4", diff --git a/public/index.html b/public/index.html index 0cf2c82d7dcdfd0db4cc4afe6f97ccc2492f573c..5a55d5b2604173be763d84d95092a495275df599 100755 --- a/public/index.html +++ b/public/index.html @@ -1,3 +1,3 @@ -<!-- 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/. --> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8" /> <meta http-equiv='cache-control' content='no-cache'/> <meta http-equiv='expires' content='0'/> <meta http-equiv='pragma' content='no-cache'/> <!-- google sign-in --> <meta name="google-signin-client_id" content="288460085642-k4veg4fo8kddvjer8b055n9da5qtgha7.apps.googleusercontent.com"> <script src="https://apis.google.com/js/platform.js" async defer></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Plataforma integrada MEC RED</title> </head> <body > <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"/> </body> </html> \ No newline at end of file +<!-- 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/. --> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8" /> <meta http-equiv='cache-control' content='no-cache'/> <meta http-equiv='expires' content='0'/> <meta http-equiv='pragma' content='no-cache'/> <!-- google sign-in --> <meta name="google-signin-client_id" content="288460085642-k4veg4fo8kddvjer8b055n9da5qtgha7.apps.googleusercontent.com"> <script src="https://apis.google.com/js/platform.js" async defer></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Plataforma integrada MEC RED</title> </head> <body > <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"/> <script src="https://www.google.com/recaptcha/api.js" async defer></script> </body> </html> \ No newline at end of file diff --git a/src/Components/CollectionCardFunction.js b/src/Components/CollectionCardFunction.js index e0c4a517972fe4cfb0fe8de5d2f97a6cd33f20e1..e09765dade75c3a4244236832b41c92bfb03ce93 100644 --- a/src/Components/CollectionCardFunction.js +++ b/src/Components/CollectionCardFunction.js @@ -22,7 +22,6 @@ import { apiDomain } from '../env'; import noAvatar from "../img/default_profile.png"; import Button from '@material-ui/core/Button'; import styled from 'styled-components' -import Slide from '@material-ui/core/Slide'; import Grid from '@material-ui/core/Grid'; import { StyledCard, CardDiv, CardReaDiv, Footer, LikeCounter, ButtonNoWidth, EnviadoPor, TagContainer, HeaderContainer, AvatarDiv } from './ResourceCardFunction.js' import Rating from '@material-ui/lab/Rating'; @@ -298,6 +297,7 @@ export default function CollectionCardFunction(props) { } <ColCardPublicOptions id={props.id} + following={userFollowingCol} handleLogin={handleLogin} currentUserId={state.currentUser.id} /> diff --git a/src/Components/PublicationPermissionsContent.js b/src/Components/PublicationPermissionsContent.js index 1159d667ac2d542368d96b490db2cc10441f3156..2f404e49217f7c9c83541ed84c3852ce94d06b65 100644 --- a/src/Components/PublicationPermissionsContent.js +++ b/src/Components/PublicationPermissionsContent.js @@ -72,7 +72,7 @@ export default function PublicationPermissionsContent (props) { <p>{question.description}</p> </Grid> <Grid item xs={2}> - <RadioGroup row name={"radio" + (index + 1)} onChange={props.handleRadios}> + <RadioGroup row name={"radio" + (question.id)} onChange={props.handleRadios}> <FormControlLabel value="Sim" control={<BlueRadio/>} label="Sim"/> <FormControlLabel value="Não" control={<BlueRadio/>} label="Não"/> </RadioGroup> </Grid> diff --git a/src/Components/ResourceCardFunction.js b/src/Components/ResourceCardFunction.js index 6648dbbd2a790f5e9b15c259268ae80c0801c21e..62aa64614e3427ad4f9617f1ac6ce3daf956ce28 100644 --- a/src/Components/ResourceCardFunction.js +++ b/src/Components/ResourceCardFunction.js @@ -27,7 +27,6 @@ import Rating from '@material-ui/lab/Rating'; import StarBorderIcon from '@material-ui/icons/StarBorder'; import FavoriteIcon from '@material-ui/icons/Favorite'; import ButtonGuardarColecao from './ButtonGuardarColecao.js' -import Slide from '@material-ui/core/Slide'; import Grid from '@material-ui/core/Grid'; import { Link } from 'react-router-dom'; import { getDefaultThumbnail } from './HelperFunctions/getDefaultThumbnail' diff --git a/src/Components/UploadPageComponents/Forms/Idioma.js b/src/Components/UploadPageComponents/Forms/Idioma.js index 7d033a44d9ef18c7ffdd55f5b7894176077d3e7d..79de2d04f8be2e66ca72f772679999af94e06b78 100644 --- a/src/Components/UploadPageComponents/Forms/Idioma.js +++ b/src/Components/UploadPageComponents/Forms/Idioma.js @@ -26,38 +26,46 @@ import Select from '@material-ui/core/Select'; export default function Idioma (props) { const [chosenLanguage, setChosenLanguage] = useState(props.initialValue ? props.initialValue : []) - const [ids, setIds] = useState(props.initialIDValues ? props.initialIDValues : []) + const [ids, setIds] = useState(props.initialIDValue ? props.initialIDValue : []) const handleChangeLanguage = (event) => { - console.log(event.target.value) let newLanguage = event.target.value.pop() - setChosenLanguage(chosenLanguage => [...chosenLanguage, newLanguage.name]); - setIds(ids => [...ids, newLanguage.id]) - }; + if (!chosenLanguage.some(language => language === newLanguage.name)) { + setChosenLanguage(chosenLanguage => [...chosenLanguage, newLanguage.name]); + setIds(ids => [...ids, newLanguage.id]) + } + else + { + if (chosenLanguage.length > 0) { + setChosenLanguage(chosenLanguage.filter((language) => {return language !== newLanguage.name})); + setIds(ids.filter((id) => {return id !== newLanguage.id})) + } + } + }; return ( - <FormControl required style={{minWidth : "30%"}}> + <FormControl style={{minWidth : "30%"}}> <StyledFormLabel component="legend" style={{fontSize : "14px", marginBottom : "10px"}}> - <b>Idioma</b> + <b>Idioma</b><span>*</span> </StyledFormLabel> - <Select - value={chosenLanguage} - multiple - renderValue={(selected) => selected.join(', ')} - name="Idioma" - onChange={handleChangeLanguage} - onBlur={() => {props.onBlurCallback("language_ids", ids, props.draftID)}} - > - { - props.languages.map( language => - <MenuItem key={language.name} value={language}> - <Checkbox checked={chosenLanguage.indexOf(language.name) > -1} /> - <ListItemText primary={language.name} /> - </MenuItem> - ) - } - </Select> + <Select + value={chosenLanguage} + multiple + renderValue={(selected) => selected.join(', ')} + name="Idioma" + onChange={handleChangeLanguage} + onBlur={() => {props.onBlurCallback("language_ids", ids, props.draftID)}} + > + { + props.languages.map( language => + <MenuItem key={language.name} value={language}> + <Checkbox checked={chosenLanguage.indexOf(language.name) > -1} /> + <ListItemText primary={language.name} /> + </MenuItem> + ) + } + </Select> </FormControl> ) } diff --git a/src/Components/UploadPageComponents/Forms/Keywords.js b/src/Components/UploadPageComponents/Forms/Keywords.js index 34c7b8ec36103d4eb27f1fbba515f2cd686ffdad..fa2418b706dc96f56f88f60f7ef1014fd66b40dd 100644 --- a/src/Components/UploadPageComponents/Forms/Keywords.js +++ b/src/Components/UploadPageComponents/Forms/Keywords.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, {useState, memo} from 'react' +import React, {useState, memo, useEffect, useRef} from 'react' import FormControl from '@material-ui/core/FormControl'; import {StyledTextField, StyledFormLabel} from '../StyledComponents.js' import FormHelperText from '@material-ui/core/FormHelperText'; @@ -27,9 +27,18 @@ function Keywords (props) { const [keywords, setKeywords] = useState(props.initialValue ? props.initialValue : []) const handleSetKeywords = (newKeyword) => {setKeywords(newKeyword)} const deleteKeyword = (keywordToDelete) => { - setKeywords(keywords.filter((keyword) => keyword !== keywordToDelete)) + handleSetKeywords(keywords.filter((keyword) => keyword !== keywordToDelete)) } + const resettingRef = useRef(false); + + useEffect(() => { + if(resettingRef.current){ //used to ensure that keywords are updated before sending (after a delete) + resettingRef.current = false; + props.onBlurCallback("tags", keywords, props.draftID); + } + },[keywords]) + const [keywordsBuffer, setKeywordsBuffer] = useState('') const handleKeywords = (event) => { @@ -64,8 +73,9 @@ function Keywords (props) { onKeyDown={(event) => { if(event.keyCode === 13){ handleSetKeywords([...keywords, keywordsBuffer]) - setKeywordsBuffer('')}} - } + setKeywordsBuffer('') + }} + } fullWidth onBlur={() => {props.onBlurCallback("tags", keywords, props.draftID)}} /> @@ -75,7 +85,7 @@ function Keywords (props) { <FormHelperText> { keywords.map( (keyword) => - <Chip label={keyword} key={keyword} onDelete={() => deleteKeyword(keyword)} /> + <Chip label={keyword} key={keyword} onDelete={() => {resettingRef.current = true; deleteKeyword(keyword);}} /> ) } </FormHelperText> diff --git a/src/Components/UploadPageComponents/PartOne.js b/src/Components/UploadPageComponents/PartOne.js index fbb47cb5b0e325fa01cf5ba7666acd454a398134..1c09b112faef0e0ebe63b01a021164edf48adee5 100644 --- a/src/Components/UploadPageComponents/PartOne.js +++ b/src/Components/UploadPageComponents/PartOne.js @@ -27,67 +27,140 @@ import TipoDeRecurso from './Forms/TipoDeRecurso.js' import Idioma from './Forms/Idioma.js' import {SendInfo} from './SendInfo.js' import {getRequest} from '../HelperFunctions/getAxiosConfig.js' +import SnackBar from '../../Components/SnackbarComponent'; export default function PartOne (props) { // {/*const [subjects, setSubjects] = useState([])*/} const [languages, setLanguages] = useState([]) const [objTypes, setObjTypes] = useState([]) + const [snackInfo, setSnackInfo] = useState({ + open: false, + text: '', + severity: '', + color: '', + }) + + function handleCloseSnackBar() { + const info = { + open: false, + text: '', + severity: '', + color: '', + } + handleSnackInfo(info) + } + + function handleSnackInfo(info) { + setSnackInfo({ + ...info + }) + } + + function checkPartOne (data) { + return ( + data.name !== null && + data.tags.length !== 0 && + data.author !== null && + data.object_type !== null && + data.language.length !== 0 && + (data.attachments.length !== 0 || + data.link !== null) + ) + } + function handleSuccessGetObjTypes (data) { setObjTypes(data.sort((a, b) => (a.name) > (b.name) ? 1 : -1)) } + + function handleSuccessGetFormData (data) { + if (checkPartOne(data)) { + props.stepperControl(1) + } else { + const info = { + open: true, + text: 'Preencha todos os campos obrigatórios, inclusive o de "Enviar Recurso"!', + severity: 'warning', + color: '#FFC125', + } + handleSnackInfo(info) + } + } + useEffect( () => { getRequest(`/object_types/`, handleSuccessGetObjTypes, (error) => {console.log(error)}) getRequest(`/languages/`, (data) => {setLanguages(data)}, (error) => {console.log(error)}) }, []) - const handleSubmit = () => { - props.stepperControl(1) + const handleSubmit = (e) => { + e.preventDefault(); + getRequest(`/learning_objects/${props.draftID}`, + handleSuccessGetFormData, + () => { + const info = { + open: true, + text: 'Não foi possível verificar o status da publicação!', + severity: 'error', + color: 'red', + } + handleSnackInfo(info) + } + ) } return ( - <form onSubmit={handleSubmit}> - {/*------------------------------Titulo-----------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <NewTitle draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Sobre------------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <SobreORecurso draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Palavras-chave------------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <Keywords draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Autor------------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <Autor draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Tipo do Objeto------------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <TipoDeRecurso objTypes={objTypes} draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Idioma------------------------------------------*/} - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <Idioma languages={languages} draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - {/*------------------------------Botoes------------------------------------------*/} - <Grid item xs={12}> - <ButtonsDiv draftID={props.draftID} stepperControl={props.stepperControl}/> - </Grid> - - <Grid item xs={12} style={{marginTop : "20px"}}> - <span style={{marginTop : "20px", fontWeight : "200", color : "#a5a5a5", paddingLeft : "10px"}}> - * Campos obrigatórios - </span> - </Grid> - </form> + <React.Fragment> + <SnackBar + snackbarOpen={snackInfo.open} + handleClose={handleCloseSnackBar} + severity={snackInfo.severity} + color={snackInfo.color} + text={snackInfo.text} + /> + + <form onSubmit={handleSubmit}> + {/*------------------------------Titulo-----------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <NewTitle draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Sobre------------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <SobreORecurso draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Palavras-chave------------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <Keywords draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Autor------------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <Autor draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Tipo do Objeto------------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <TipoDeRecurso objTypes={objTypes} draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Idioma------------------------------------------*/} + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <Idioma languages={languages} draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + {/*------------------------------Botoes------------------------------------------*/} + <Grid item xs={12}> + <ButtonsDiv draftID={props.draftID} stepperControl={props.stepperControl}/> + </Grid> + + <Grid item xs={12} style={{marginTop : "20px"}}> + <span style={{marginTop : "20px", fontWeight : "200", color : "#a5a5a5", paddingLeft : "10px"}}> + * Campos obrigatórios + </span> + </Grid> + </form> + </React.Fragment> ) } diff --git a/src/Components/UploadPageComponents/PartThree.js b/src/Components/UploadPageComponents/PartThree.js index b1eb3f564739b77c4c13ffb2e5e6a04a2699004d..a5d0810784f9475418ec7004ea419f62c564e367 100644 --- a/src/Components/UploadPageComponents/PartThree.js +++ b/src/Components/UploadPageComponents/PartThree.js @@ -35,11 +35,13 @@ import { GrayButton, OrangeButton } from './StyledComponents'; import ModalCancelar from './ModalCancelar.js' import { getDefaultThumbnail } from '../HelperFunctions/getDefaultThumbnail' import { getRequest } from '../HelperFunctions/getAxiosConfig.js' +import ReCaptcha from 'react-recaptcha' export default function PartThree(props) { var moment = require('moment') const { state } = useContext(Store) const [loading, setLoading] = useState(false) + const [unavailableButton, setButtonAvailability] = useState(true); const [draft, setDraft] = useState({}) const [subjects, setSubjects] = useState('') @@ -84,6 +86,12 @@ export default function PartThree(props) { return (state.currentUser.roles.filter((role) => role.name === userRole).length > 0) } + function captchaVerified (response) { + if (response) { + setButtonAvailability(false) + } + } + return ( <React.Fragment> { @@ -206,7 +214,11 @@ export default function PartThree(props) { </Grid> <Grid item xs={windowWidth > 990 ? 6 : 12} style={{ paddingRight: "15px", paddingLeft: "15px", textAlign: windowWidth > 990 ? 'left' : 'center' }}> - <span>Recaptcha</span> + { + //<ReCaptcha sitekey={process.env.REACT_APP_SITE_KEY} verifyCallback={captchaVerified} /> //when key set in env + //<ReCaptcha sitekey="6LfxuKUUAAAAAIzYpCzEtJyeE8QRjBYa44dvHlTX" verifyCallback={captchaVerified} /> //use this one on production + <ReCaptcha sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" verifyCallback={captchaVerified} /> //test key, from google, do not use this one on production + } </Grid> <Grid item xs={12} style={{ paddingRight: "15px", paddingLeft: "15px", marginTop: "30px", textAlign: 'center' }}> <GrayButton onClick={() => { props.stepperControl(-1) }}>VOLTAR</GrayButton> @@ -214,11 +226,11 @@ export default function PartThree(props) { { checkAccessLevel("partner") ? ( - <OrangeButton onClick={props.handlePost}>PUBLICAR RECURSO</OrangeButton> + <OrangeButton onClick={props.handlePost} disabled={unavailableButton}>PUBLICAR RECURSO</OrangeButton> ) : ( - <OrangeButton onClick={props.handleSubmit}>SUBMETER RECURSO</OrangeButton> + <OrangeButton onClick={props.handleSubmit} disabled={unavailableButton}>SUBMETER RECURSO</OrangeButton> ) } diff --git a/src/Components/UploadPageComponents/PartTwo.js b/src/Components/UploadPageComponents/PartTwo.js index 221998c85f4e04e0a35204fcb89bd675b95b68f0..0c7b571cf60023ff4c9b38bfb34858a4337d9dd4 100644 --- a/src/Components/UploadPageComponents/PartTwo.js +++ b/src/Components/UploadPageComponents/PartTwo.js @@ -33,6 +33,7 @@ import EditThumbnail from './PartTwoComponents/EditThumbnail.js' import DisplayThumbnail from './PartTwoComponents/DisplayThumbnail.js' import CustomCircularProgress from './PartTwoComponents/CustomCircularProgress'; import {getRequest, putRequest} from '../HelperFunctions/getAxiosConfig.js' +import SnackBar from '../../Components/SnackbarComponent'; export function LoadingDiv () { return ( @@ -46,12 +47,57 @@ export default function PartTwo (props) { const [eduStages, setEduStages] = useState([]) const [subjects, setSubjects] = useState([]) const [themes, setThemes] = useState([]) + const [snackInfo, setSnackInfo] = useState({ + open: false, + text: '', + severity: '', + color: '', + }) + + function handleCloseSnackBar() { + const info = { + open: false, + text: '', + severity: '', + color: '', + } + handleSnackInfo(info) + } + + function handleSnackInfo(info) { + setSnackInfo({ + ...info + }) + } function handleSuccess (data) { setSubjects(data.filter(subject => subject.theme === false).sort((a,b) => a.name > b.name ? 1 : -1)) setThemes(data.filter(subject => subject.theme === true).sort((a,b) => a.name > b.name ? 1 : -1)) } + function checkPartTwo (data) { + return ( + data.educational_stages.length !== 0 && + data.subjects.length !== 0 && + data.license !== null && + termsCheckbox + ) + } + + function handleSuccessGetFormData (data) { + if (checkPartTwo(data)) { + props.stepperControl(1) + } else { + const info = { + open: true, + text: 'Preencha todos os campos obrigatórios, inclusive o acordo de termos de uso e de propriedade intelectual!', + severity: 'warning', + color: '#FFC125', + } + handleSnackInfo(info) + } + } + useEffect(() => { getRequest(`/educational_stages/`, (data) => {setEduStages(data)}, (error) => {console.log(error)}) @@ -62,8 +108,8 @@ export default function PartTwo (props) { /*------------------------Licenca------------------------*/ const [termsCheckbox, setChecked] = useState(false) - const toggleCheckbox = (event) => { - setChecked(event.target.checked) + const toggleCheckbox = () => { + setChecked(!termsCheckbox) } const [thumbnail, setThumbnail] = useState('') @@ -107,46 +153,67 @@ export default function PartTwo (props) { } } - const handleSubmit = () => { - props.stepperControl(1) - } + const handleSubmit = (e) => { + e.preventDefault(); + getRequest(`/learning_objects/${props.draftID}`, + handleSuccessGetFormData, + () => { + const info = { + open: true, + text: 'Não foi possível verificar o status da publicação!', + severity: 'error', + color: 'red', + } + handleSnackInfo(info) + } + ) + } return ( - <form style={{width : "100%"}} onSubmit={handleSubmit}> - <Grid item xs={12} style={{paddingBottom : "40px"}}> - {chooseRenderStageThumbnail()} - </Grid> - - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <EducationalStage draftID={props.draftID} eduStages={eduStages} onBlurCallback={SendInfo}/> - </Grid> - - <SubjectsAndThemes draftID={props.draftID} subjects={subjects} themes={themes} onUploadPage={true} onBlurCallback={SendInfo}/> - - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <Licenca draftID={props.draftID} onBlurCallback={SendInfo}/> - </Grid> - - <Grid item xs={12} style={{paddingBottom : "40px"}}> - <StyledFormControl required > - <StyledFormLabel component="legend" style={{fontSize : "14px", marginBottom : "10px"}} onClick={() => window.open("/termos/", "_blank")}> - <b>Confirme se você concorda com os <strong style={{color : "#ff7f00"}}>termos de uso e de propriedade intelectual</strong></b> - </StyledFormLabel> - <FormControlLabel label={<span className="label">Li e concordo com os termos de uso e de propriedade intelectual.</span>} control={<Checkbox checked={termsCheckbox} onChange={toggleCheckbox}/>} - /> - </StyledFormControl> - </Grid> - - <Grid item xs={12}> - <ButtonsDiv draftID={props.draftID} stepperControl={props.stepperControl} onPartTwo={true}/> - </Grid> - - <Grid item xs={12} style={{marginTop : "20px"}}> - <span style={{marginTop : "20px", fontWeight : "200", color : "#a5a5a5", paddingLeft : "10px"}}> - * Campos obrigatórios - </span> - </Grid> - </form> + <React.Fragment> + <SnackBar + snackbarOpen={snackInfo.open} + handleClose={handleCloseSnackBar} + severity={snackInfo.severity} + color={snackInfo.color} + text={snackInfo.text} + /> + <form style={{width : "100%"}} onSubmit={handleSubmit}> + <Grid item xs={12} style={{paddingBottom : "40px"}}> + {chooseRenderStageThumbnail()} + </Grid> + + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <EducationalStage draftID={props.draftID} eduStages={eduStages} onBlurCallback={SendInfo}/> + </Grid> + + <SubjectsAndThemes draftID={props.draftID} subjects={subjects} themes={themes} onUploadPage={true} onBlurCallback={SendInfo}/> + + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <Licenca draftID={props.draftID} onBlurCallback={SendInfo}/> + </Grid> + + <Grid item xs={12} style={{paddingBottom : "40px"}}> + <StyledFormControl required > + <StyledFormLabel component="legend" style={{fontSize : "14px", marginBottom : "10px"}} onClick={() => window.open("/termos/", "_blank")}> + <b>Confirme se você concorda com os <strong style={{color : "#ff7f00"}}>termos de uso e de propriedade intelectual</strong></b> + </StyledFormLabel> + <FormControlLabel label={<span className="label">Li e concordo com os termos de uso e de propriedade intelectual.</span>} control={<Checkbox checked={termsCheckbox} onChange={toggleCheckbox}/>} + /> + </StyledFormControl> + </Grid> + + <Grid item xs={12}> + <ButtonsDiv draftID={props.draftID} stepperControl={props.stepperControl} onPartTwo={true}/> + </Grid> + + <Grid item xs={12} style={{marginTop : "20px"}}> + <span style={{marginTop : "20px", fontWeight : "200", color : "#a5a5a5", paddingLeft : "10px"}}> + * Campos obrigatórios + </span> + </Grid> + </form> + </React.Fragment> ) } diff --git a/src/Components/UploadPageComponents/SendInfo.js b/src/Components/UploadPageComponents/SendInfo.js index ebcb1b95f377fe018e3a178716ff7d1621009dba..606a7f72c7bb97e7b7eda26a95a76ca5bcc29e4a 100644 --- a/src/Components/UploadPageComponents/SendInfo.js +++ b/src/Components/UploadPageComponents/SendInfo.js @@ -23,8 +23,8 @@ export function SendInfo (fieldName, payload, draftID) { const key = fieldName let value = payload if (key === "tags") { - value = payload.map( (tag, index) => - index = { "name" : tag} + value = payload.map( (tag, index) => { + return (index = { "name" : tag})} ) } diff --git a/src/Pages/PublicationPermissionsPage.js b/src/Pages/PublicationPermissionsPage.js index d7dcb6ac34900cb4155629e3382997be37650f10..52bdbd8a8caf5b3b2ff7cfb465b230ac120206bb 100644 --- a/src/Pages/PublicationPermissionsPage.js +++ b/src/Pages/PublicationPermissionsPage.js @@ -95,8 +95,7 @@ export default function PermissionsContainer(props) { temp[e.target.name] = e.target.value; setRadioValues(temp); - - setCheckboxAvailability(!(radios.radio1 && radios.radio2 && radios.radio3)); + setCheckboxAvailability(!(radios.radio1 === "Não" && radios.radio2 === "Não" && radios.radio3 === "Não")); }; const handleAgreement = () => { @@ -144,7 +143,7 @@ export default function PermissionsContainer(props) { <div> <div style={{ fontSize: "14px" }}> <LabeledCheckbox - disabledCheckbox={unavailableCheckbox} + disabled={unavailableCheckbox} label={ <Styledspan> Li e permito a publicação do meu recurso na @@ -159,9 +158,9 @@ export default function PermissionsContainer(props) { style={{ justifyContent: "center", display: "flex" }} > <Button - disabled={unavailableButton} + disabled={unavailableButton || unavailableCheckbox} style={ - unavailableButton + unavailableButton || unavailableCheckbox ? { backgroundColor: "#e9e9e9" } : { backgroundColor: "#00bcd4" } } @@ -169,7 +168,7 @@ export default function PermissionsContainer(props) { > <Styledspan style={ - unavailableButton + unavailableButton || unavailableCheckbox ? { color: "#666666", fontWeight : "600" } : { color: "#ffffff", fontWeight : "600" } }