diff --git a/src/components/fieldsDisplayForm/FormFieldTitle.js b/src/components/fieldsDisplayForm/FormFieldTitle.js index 8eff7e505cb88319adec5bdc7ff9e6092b3bee8c..257f5ecfcd613ffa420e208507175fd993ff8930 100644 --- a/src/components/fieldsDisplayForm/FormFieldTitle.js +++ b/src/components/fieldsDisplayForm/FormFieldTitle.js @@ -26,6 +26,7 @@ const useStyles = makeStyles((theme) => ({ }, title: { fontSize: "x-large", + lineHeight: "normal", }, description: { fontSize: "large", @@ -60,6 +61,7 @@ function FormFieldText(props) { input: classes.title, }, }} + InputLabelProps={classes.test} /> {props.error ? ( <Grid className={classes.errorGrid}> diff --git a/src/components/fieldsDisplayForm/utils/schemas.js b/src/components/fieldsDisplayForm/utils/schemas.js index 95c57f612112d3e752aea1032270fc6e7f12678f..deae1e92600c94c946fcf3be691587ef86539e3d 100644 --- a/src/components/fieldsDisplayForm/utils/schemas.js +++ b/src/components/fieldsDisplayForm/utils/schemas.js @@ -8,9 +8,7 @@ function checkText(value) { /** Function that applies the validation of it's used schema and sets the error messages. */ export async function testQuestionTextSchema(error, value) { value - ? checkText(value) - ? (error.errorMsg.question = "") - : (error.errorMsg.question = "O caractere não é permitido") + ? (error.errorMsg.question = "") : (error.errorMsg.question = "Este campo é obrigatório!"); } /** Function that applies the validation of it's used schema and sets the error messages. */ @@ -73,9 +71,7 @@ export async function testSubformSchema(form, index) { /** Function that applies the validation of it's used schema and sets the error messages. */ export async function selectOptionTextTesting(error, value, idopt) { value - ? checkText(value) - ? (error.errorMsg.options[idopt] = "") - : (error.errorMsg.options[idopt] = "O caractere não é permitido") + ? (error.errorMsg.options[idopt] = "") : (error.errorMsg.options[idopt] = "Por favor, preencha esta opção"); } /** Schema to validate the quantity field of the validation from FormFieldText. */ diff --git a/src/contexts/useForm.js b/src/contexts/useForm.js index 03c0d60ab8c144be115b386d7de5659d7a89682e..54e817470374a89f7a98a5721bbfc3494b439e92 100644 --- a/src/contexts/useForm.js +++ b/src/contexts/useForm.js @@ -8,7 +8,7 @@ import { selectOptionsTesting, testSubformSchema, selectOptionTextTesting, - testTextValidation + testTextValidation, } from "../components/fieldsDisplayForm/utils/schemas"; import { pushTitle, @@ -16,7 +16,7 @@ import { pushSelect, pushRadio, pushCheckbox, - pushSubform + pushSubform, } from "../components/fieldsDisplayForm/utils/FormComposition"; import api from "../api"; @@ -148,7 +148,6 @@ const useForm = () => { */ async function setDescriptionField(value, index) { form[index].description = value; - testDescriptionTextSchema(form[index].error, value); setForm([...form]); } @@ -238,7 +237,7 @@ const useForm = () => { */ async function setId() { const fetchData = async () => { - await api.get(`/form/${routeId}`).then(async function(res) { + await api.get(`/form/${routeId}`).then(async function (res) { let backForm = createFrontendForm(res.data); for (let i = 1; i < backForm.length; i++) { for (let j = 1; j < form.length; j++) { @@ -248,13 +247,13 @@ const useForm = () => { "question", "description", "options", - "subformId" + "subformId", ]) !== JSON.stringify(form[j], [ "question", "description", "options", - "subformId" + "subformId", ]) || differentValidation(backForm[i], form[j]) ) { @@ -279,17 +278,17 @@ const useForm = () => { const post_response = await api .put(`/form/${routeId}`, data, { headers: { - authorization: `bearer ${window.sessionStorage.getItem("token")}` - } + authorization: `bearer ${window.sessionStorage.getItem("token")}`, + }, }) - .then(function(error) { + .then(function (error) { if (!error.response) { alert("Seu formulário foi atualizado com sucesso."); let path = `/signin`; history.push(path); } }) - .catch(function(error) { + .catch(function (error) { if (error.response.status === 401) { let path = `/signin`; history.push(path); @@ -307,17 +306,17 @@ const useForm = () => { const post_response = await api .post(`/form`, await createBackendForm(form), { headers: { - authorization: `bearer ${window.sessionStorage.getItem("token")}` - } + authorization: `bearer ${window.sessionStorage.getItem("token")}`, + }, }) - .then(function(error) { + .then(function (error) { if (!error.response) { alert("Seu formulário foi criado com sucesso."); let path = `/signin`; history.push(path); } }) - .catch(function(error) { + .catch(function (error) { alert("Um erro ocorreu."); }); } @@ -343,7 +342,7 @@ const useForm = () => { setValidationValue, removeValidation, onDragEnd, - submit + submit, }; };