From ced646cfe4ad472de8806a400cb98f720ccae255 Mon Sep 17 00:00:00 2001 From: Richard Fernando Heise Ferreira <rfhf19@inf.ufpr.br> Date: Fri, 24 Jul 2020 09:23:49 -0300 Subject: [PATCH] Issue #22: Fix answer page form description. --- .../fieldsAnswerForm/FormFieldTitle.js | 70 +++++++++---------- src/pages/AnswerForm.js | 24 +++++-- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/components/fieldsAnswerForm/FormFieldTitle.js b/src/components/fieldsAnswerForm/FormFieldTitle.js index cf2c22e..9a41a54 100644 --- a/src/components/fieldsAnswerForm/FormFieldTitle.js +++ b/src/components/fieldsAnswerForm/FormFieldTitle.js @@ -10,7 +10,7 @@ const useStyles = makeStyles(theme => ({ paper: { padding: theme.spacing(3), width: theme.spacing(100), - height: theme.spacing(22), + height: "40%", margin: theme.spacing(2), color: "#000000", ["@media (max-width:827px)"]: { @@ -38,10 +38,10 @@ const useStyles = makeStyles(theme => ({ } }, description: { - fontSize: "30px", + fontSize: "25px", color: "#000000", ["@media (max-width:827px)"]: { - fontSize: "25px" + fontSize: "20px" }, ["@media (max-width:590px)"]: { fontSize: "15px" @@ -53,40 +53,38 @@ function FormFieldText(props) { const classes = useStyles(); return ( - <Grid> - <Paper className={classes.paper}> - <Grid container> - <Grid item xs={12} className={classes.questionsGrid}> - <Typography - style={{ wordWrap: "break-word" }} - className={classes.title} - variant="h3" - gutterBottom - > - {props.title} - </Typography> - </Grid> - <Grid item xs={9} className={classes.questionsGrid}> - <Typography - style={{ wordWrap: "break-word" }} - className={classes.description} - variant="h4" - gutterBottom - > - {props.description} - </Typography> - </Grid> - <Grid - item - container - direction="row" - justify="flex-end" - alignItems="flex-end" - xs={3} - ></Grid> + <Paper className={classes.paper}> + <Grid container> + <Grid item xs={12} className={classes.questionsGrid}> + <Typography + style={{ wordWrap: "break-word" }} + className={classes.title} + variant="h3" + gutterBottom + > + {props.title} + </Typography> + </Grid> + <Grid item xs={12} className={classes.questionsGrid}> + <Typography + style={{ wordWrap: "break-word" }} + className={classes.description} + variant="h6" + gutterBottom + > + {props.description} + </Typography> </Grid> - </Paper> - </Grid> + <Grid + item + container + direction="row" + justify="flex-end" + alignItems="flex-end" + xs={3} + ></Grid> + </Grid> + </Paper> ); } diff --git a/src/pages/AnswerForm.js b/src/pages/AnswerForm.js index f09d9e0..47fc791 100644 --- a/src/pages/AnswerForm.js +++ b/src/pages/AnswerForm.js @@ -164,6 +164,10 @@ function AnwserForm() { .post(`/answer/${id}`, backendTranslation()) .then(function(res) { alert("Formulário respondido!"); + }) + .catch(error => { + alert("Ocorreu um erro ao responder seu formulário."); + return; }); } @@ -200,10 +204,22 @@ function AnwserForm() { * @param id - Form id got from the broswer's URL */ async function getForm(id) { - const res = await api.get(`/form/${id}`).then(function(res) { - setFormData(res.data); - mapInputs(res.data); - }); + const res = await api + .get(`/form/${id}`) + .then(function(res) { + setFormData(res.data); + mapInputs(res.data); + }) + .catch(error => { + if (error.response.status === 401) { + alert("Você não está logado."); + return; + } + if (error.response.status === 500) { + alert("Ocorreu um erro: formulário não encontrado."); + return; + } + }); } /** First thing the page does is getting the form from the API. */ -- GitLab