Skip to content
Snippets Groups Projects
Commit ad382e51 authored by vgm18's avatar vgm18
Browse files

Fixing bugs reported since 21/05 in the spreadsheet

parent c97c93ba
Branches
Tags
3 merge requests!69Fixed upload page: recaptcha not implemented, lack of blocking (part one, two,...,!61Fixed upload page: recaptcha not implemented, lack of blocking (part one, two,...,!60Fixed upload page: recaptcha not implemented, lack of blocking (part one, two,...
......@@ -104,7 +104,12 @@ export default function TextoObjeto (props) {
return (
<TextoObjetoDiv>
{ publisherDeletedObject &&
<Redirect to="/"/>
<Redirect
to={{
pathname: "/perfil",
state: 1
}}
/>
}
<Snackbar open={snackbarOpen} autoHideDuration={1000} onClose={() => {toggleSnackbar(false)}}
anchorOrigin = {{ vertical:'top', horizontal:'right' }}
......
......@@ -28,6 +28,7 @@ import {apiUrl} from '../env.js'
import {GoogleLoginButton} from './LoginContainerFunction'
import ValidateUserInput from './HelperFunctions/FormValidationFunction.js'
import GoogleLogo from "../img/logo_google.svg"
import ReCaptcha from 'react-recaptcha'
async function handleGoogleAttempt () {
console.log("handleGoogleAttempt")
......@@ -37,6 +38,8 @@ async function handleGoogleAttempt () {
window.location.replace(request_url)
}
export default function SignUpContainer (props) {
const [unavailableButton, setButtonAvailability] = useState(true);
const [formNome, setNome] = useState(
{
key : false,
......@@ -137,6 +140,12 @@ export default function SignUpContainer (props) {
}
}
function captchaVerified (response) {
if (response) {
setButtonAvailability(false)
}
}
return (
<ContainerStyled >
<DialogHeaderStyled>
......@@ -208,8 +217,17 @@ export default function SignUpContainer (props) {
help = {formConfirmation.key ? (formConfirmation.value.length === 0 ? "Faltou digitar sua senha." : (formConfirmation.value !== formSenha.value ? "As senhas precisam ser iguais" : "A senha precisa ter no mínimo 8 caracteres.")) : ""}
/>
<br/>
<div style={{margin:"0 auto", width: "304px"}}>
{
//<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
}
</div>
<ConfirmContainerStyled>
<StyledSignUpButton type="submit" variant="contained">
<StyledSignUpButton type="submit" variant="contained" disabled={unavailableButton}
style={unavailableButton ? { backgroundColor: "#e9e9e9" } : { backgroundColor: "#00bcd4" }}
>
<span
style={{paddingLeft:"16px", paddingRight:"16px", borderRadius:"3px", boxSizing:"border-box",
fontFamily:"Roboto, sans serif", fontWeight:"500", color:"#fff"}}
......@@ -335,7 +353,6 @@ const ConfirmContainerStyled = styled.div`
`
const StyledSignUpButton = styled(Button)`
background-color: #00bcd4 !important;
box-shadow : none !important;
outline: none !important;
border : 0 !important;
......
......@@ -16,7 +16,8 @@ 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, useEffect} from 'react'
import React, {useState, useEffect, useContext, useRef} from 'react'
import {Store} from '../../Store.js'
import Grid from '@material-ui/core/Grid';
import ButtonsDiv from './ButtonsDiv.js'
import SobreORecurso from './Forms/SobreORecurso.js'
......@@ -28,12 +29,22 @@ import Idioma from './Forms/Idioma.js'
import {SendInfo} from './SendInfo.js'
import {getRequest} from '../HelperFunctions/getAxiosConfig.js'
import SnackBar from '../../Components/SnackbarComponent';
import LoadingSpinner from '../../Components/LoadingSpinner'
export default function PartOne (props) {
// {/*const [subjects, setSubjects] = useState([])*/}
const {state} = useContext(Store)
const didMountRef = useRef(false);
const didMountRefObj = useRef(false);
const [languages, setLanguages] = useState([])
const [objTypes, setObjTypes] = useState([])
const [learningObject, setLearningObject] = useState({})
const [loading, toggleLoading] = useState(true)
const [loadingObj, toggleLoadingObj] = useState(true)
const [snackInfo, setSnackInfo] = useState({
open: false,
text: '',
......@@ -87,12 +98,36 @@ export default function PartOne (props) {
}
}
function handleSuccessfulGet (data) {
setLearningObject(data)
}
useEffect( () => {
getRequest(`/object_types/`, handleSuccessGetObjTypes, (error) => {console.log(error)})
getRequest(`/languages/`, (data) => {setLanguages(data)}, (error) => {console.log(error)})
const url = `/learning_objects/${props.draftID}`
getRequest(url, handleSuccessfulGet, (error) => {console.log(error)})
}, [])
useEffect( () => {
if (didMountRef.current) {
toggleLoading(false)
}
else {
didMountRef.current = true;
}
}, [learningObject])
useEffect( () => {
if (didMountRefObj.current) {
toggleLoadingObj(false)
}
else {
didMountRefObj.current = true;
}
}, [objTypes])
const handleSubmit = (e) => {
e.preventDefault();
getRequest(`/learning_objects/${props.draftID}`,
......@@ -118,36 +153,50 @@ export default function PartOne (props) {
color={snackInfo.color}
text={snackInfo.text}
/>
{
!loading && !loadingObj ? (
<form onSubmit={handleSubmit}>
{/*------------------------------Titulo-----------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<NewTitle draftID={props.draftID} onBlurCallback={SendInfo}/>
<NewTitle draftID={props.draftID} onBlurCallback={SendInfo} initialValue={learningObject.name}/>
</Grid>
{/*------------------------------Sobre------------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<SobreORecurso draftID={props.draftID} onBlurCallback={SendInfo}/>
<SobreORecurso draftID={props.draftID} onBlurCallback={SendInfo} initialValue={learningObject.description}/>
</Grid>
{/*------------------------------Palavras-chave------------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Keywords draftID={props.draftID} onBlurCallback={SendInfo}/>
<Keywords draftID={props.draftID} onBlurCallback={SendInfo} initialValue={learningObject.tags !== undefined ? learningObject.tags.map((tag) => tag.name) : null}/>
</Grid>
{/*------------------------------Autor------------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Autor draftID={props.draftID} onBlurCallback={SendInfo}/>
<Autor draftID={props.draftID} onBlurCallback={SendInfo}
initialValue={
learningObject.author === state.currentUser.name ?
0 : 1
}
initialOutroAutor={
learningObject.author !== state.currentUser.name ?
learningObject.author : ''
}
/>
</Grid>
{/*------------------------------Tipo do Objeto------------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<TipoDeRecurso objTypes={objTypes} draftID={props.draftID} onBlurCallback={SendInfo}/>
<TipoDeRecurso objTypes={objTypes} draftID={props.draftID} onBlurCallback={SendInfo}
initialValue={learningObject.object_type !== undefined && learningObject.object_type !== null ? objTypes.filter((type) => type.name === learningObject.object_type)[0].id : null}
/>
</Grid>
{/*------------------------------Idioma------------------------------------------*/}
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Idioma languages={languages} draftID={props.draftID} onBlurCallback={SendInfo}/>
<Idioma languages={languages} draftID={props.draftID} onBlurCallback={SendInfo}
initialValue={learningObject.language !== undefined ? learningObject.language.map((language) => language.name) : null} initialIDValues={learningObject.language !== undefined ? learningObject.language.map((language) => language.id) : null}
/>
</Grid>
{/*------------------------------Botoes------------------------------------------*/}
......@@ -161,6 +210,12 @@ export default function PartOne (props) {
</span>
</Grid>
</form>
)
:
(
<LoadingSpinner text={"CARREGANDO"}/>
)
}
</React.Fragment>
)
}
......@@ -213,12 +213,14 @@ export default function PartThree(props) {
</span>
</Grid>
<Grid item xs={windowWidth > 990 ? 6 : 12} style={{ paddingRight: "15px", paddingLeft: "15px", textAlign: windowWidth > 990 ? 'left' : 'center' }}>
<Grid item xs={windowWidth > 990 ? 6 : 12} style={{ paddingRight: "15px", paddingLeft: "15px"}}>
<div style={{margin:"0 auto", width: "304px"}}>
{
//<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
}
</div>
</Grid>
<Grid item xs={12} style={{ paddingRight: "15px", paddingLeft: "15px", marginTop: "30px", textAlign: 'center' }}>
<GrayButton onClick={() => { props.stepperControl(-1) }}>VOLTAR</GrayButton>
......@@ -226,11 +228,23 @@ export default function PartThree(props) {
{
checkAccessLevel("partner") ?
(
<OrangeButton onClick={props.handlePost} disabled={unavailableButton}>PUBLICAR RECURSO</OrangeButton>
unavailableButton ? (
<GrayButton disabled={unavailableButton}>PUBLICAR RECURSO</GrayButton>
)
:
(
<OrangeButton onClick={props.handlePost}>PUBLICAR RECURSO</OrangeButton>
)
)
:
(
<OrangeButton onClick={props.handleSubmit} disabled={unavailableButton}>SUBMETER RECURSO</OrangeButton>
unavailableButton ? (
<GrayButton disabled={unavailableButton}>SUBMETER RECURSO</GrayButton>
)
:
(
<OrangeButton onClick={props.handleSubmit}>SUBMETER RECURSO</OrangeButton>
)
)
}
......
......@@ -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, useEffect} from 'react'
import React, {useState, useEffect, useRef} from 'react'
import Grid from '@material-ui/core/Grid';
import styled from 'styled-components'
import DragAndDropThumbnail from './PartTwoComponents/DragAndDropThumbnail'
......@@ -34,6 +34,7 @@ import DisplayThumbnail from './PartTwoComponents/DisplayThumbnail.js'
import CustomCircularProgress from './PartTwoComponents/CustomCircularProgress';
import {getRequest, putRequest} from '../HelperFunctions/getAxiosConfig.js'
import SnackBar from '../../Components/SnackbarComponent';
import LoadingSpinner from '../../Components/LoadingSpinner'
export function LoadingDiv () {
return (
......@@ -44,9 +45,16 @@ export function LoadingDiv () {
}
export default function PartTwo (props) {
const didMountRef = useRef(false);
const [eduStages, setEduStages] = useState([])
const [subjects, setSubjects] = useState([])
const [themes, setThemes] = useState([])
const [learningObject, setLearningObject] = useState({})
const [loading, toggleLoading] = useState(true)
const [snackInfo, setSnackInfo] = useState({
open: false,
text: '',
......@@ -98,12 +106,29 @@ export default function PartTwo (props) {
}
}
function handleSuccessfulGet (data) {
setLearningObject(data)
}
useEffect(() => {
getRequest(`/educational_stages/`, (data) => {setEduStages(data)}, (error) => {console.log(error)})
getRequest(`/subjects/`, handleSuccess, (error) => {console.log(error)})
const url = `/learning_objects/${props.draftID}`
getRequest(url, handleSuccessfulGet, (error) => {console.log(error)})
}, [])
useEffect( () => {
if (didMountRef.current) {
console.log(learningObject);
toggleLoading(false)
}
else {
didMountRef.current = true;
}
}, [learningObject])
/*------------------------Licenca------------------------*/
......@@ -178,19 +203,25 @@ export default function PartTwo (props) {
color={snackInfo.color}
text={snackInfo.text}
/>
{
!loading ? (
<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}/>
<EducationalStage draftID={props.draftID} eduStages={eduStages} onBlurCallback={SendInfo}
initialValue={learningObject.educational_stages !== null ? learningObject.educational_stages.map((stage) => String(stage.id)) : null}
/>
</Grid>
<SubjectsAndThemes draftID={props.draftID} subjects={subjects} themes={themes} onUploadPage={true} onBlurCallback={SendInfo}/>
<SubjectsAndThemes draftID={props.draftID} subjects={subjects} themes={themes} onUploadPage={true} onBlurCallback={SendInfo}
initialValue={learningObject.subjects !== null ? learningObject.subjects.map(subject => String(subject.id)) : null}
/>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Licenca draftID={props.draftID} onBlurCallback={SendInfo}/>
<Licenca draftID={props.draftID} onBlurCallback={SendInfo} initialValue={learningObject.license ? learningObject.license.id : null}/>
</Grid>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
......@@ -213,6 +244,12 @@ export default function PartTwo (props) {
</span>
</Grid>
</form>
)
:
(
<LoadingSpinner text={"CARREGANDO"}/>
)
}
</React.Fragment>
)
}
......
......@@ -24,6 +24,7 @@ import Grid from '@material-ui/core/Grid';
import UploadFileWrapper from '../Components/UploadPageComponents/UploadFileWrapper.js'
import Alert from '../Components/Alert.js';
import Snackbar from '@material-ui/core/Snackbar';
import {Redirect} from 'react-router-dom'
import {GreyButton, OrangeButton, InfoBox} from '../Components/UploadPageComponents/StyledComponents.js'
import {Background} from '../Components/UploadPageComponents/StyledComponents'
import LoadingSpinner from '../Components/LoadingSpinner'
......@@ -46,6 +47,7 @@ export default function EditLearningObjectPage (props) {
const recursoId = props.match.params.recursoId
const {state} = useContext(Store)
const [learningObject, setLearningObject] = useState({})
const [publisherDeletedObject, toggleDeleted] = useState(false)
const [objTypes, setObjTypes] = useState([])
const [languages, setLanguages] = useState([])
const [eduStages, setEduStages] = useState([])
......@@ -115,7 +117,7 @@ export default function EditLearningObjectPage (props) {
function handleSuccessfulDelete (data) {
toggleSnackbar(true)
props.history.push("/")
toggleDeleted(true)
}
const handleDelete = () => {
......@@ -237,6 +239,15 @@ export default function EditLearningObjectPage (props) {
}
return (
<React.Fragment>
{
publisherDeletedObject &&
<Redirect
to={{
pathname: "/perfil",
state: 1
}}
/>
}
<Snackbar open={snackbarOpen} autoHideDuration={1000} onClose={() => {toggleSnackbar(false)}}
anchorOrigin = {{ vertical:'top', horizontal:'right' }}
>
......@@ -276,7 +287,7 @@ export default function EditLearningObjectPage (props) {
</Grid>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Keywords draftID={learningObject.id} initialValue={learningObject.tags.map((tag) => tag.name)}
<Keywords draftID={learningObject.id} initialValue={learningObject.tags !== undefined ? learningObject.tags.map((tag) => tag.name) : null}
onBlurCallback={onBlurCallback}/>
</Grid>
......@@ -296,20 +307,21 @@ export default function EditLearningObjectPage (props) {
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<TipoDeRecurso objTypes={objTypes} draftID={learningObject.id}
initialValue={learningObject.object_type !== null ? objTypes.filter((type) => type.name === learningObject.object_type)[0].id : null} onBlurCallback={onBlurCallback} />
initialValue={learningObject.object_type !== undefined && learningObject.object_type !== null ? objTypes.filter((type) => type.name === learningObject.object_type)[0].id : null} onBlurCallback={onBlurCallback} />
</Grid>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Idioma languages={languages} draftID={learningObject.id} initialValue={learningObject.language.map((language) => language.name)} initialIDValues={learningObject.language.map((language) => language.id)}
<Idioma languages={languages} draftID={learningObject.id}
initialValue={learningObject.language !== undefined ? learningObject.language.map((language) => language.name) : null} initialIDValues={learningObject.language !== undefined ? learningObject.language.map((language) => language.id) : null}
onBlurCallback={onBlurCallback} />
</Grid>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<EducationalStage draftID={learningObject.id} eduStages={eduStages} initialValue={learningObject.educational_stages.map((stage) => String(stage.id))} onBlurCallback={onBlurCallback}
<EducationalStage draftID={learningObject.id} eduStages={eduStages} initialValue={learningObject.educational_stages !== null ? learningObject.educational_stages.map((stage) => String(stage.id)) : null} onBlurCallback={onBlurCallback}
/>
</Grid>
<SubjectsAndThemes draftId={learningObject.id} subjects={subjects} initialValue={learningObject.subjects.map(subject => String(subject.id))} onBlurCallback={onBlurCallback}/>
<SubjectsAndThemes draftId={learningObject.id} subjects={subjects} initialValue={learningObject.subjects !== null ? learningObject.subjects.map(subject => String(subject.id)) : null} onBlurCallback={onBlurCallback}/>
<Grid item xs={12} style={{paddingBottom : "40px"}}>
<Licenca draftID={learningObject.id} initialValue={learningObject.license ? learningObject.license.id : null} onBlurCallback={onBlurCallback}/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment