diff --git a/src/components/header/header.jsx b/src/components/header/header.jsx index 64486a923643060c0804be0bb81cb641a41f5ebd..8c6648538075ad8e5f03337276d83f0701cffa9c 100644 --- a/src/components/header/header.jsx +++ b/src/components/header/header.jsx @@ -109,7 +109,11 @@ export default function Header() { </Grid> </Grid> <Grid container item xs={6} sm={6} md={4} justify="center"> - <a className={classes.link}> + <a + href="https://genforms.c3sl.ufpr.br/" + title="Home" + className={classes.link} + > <h2 className={classes.form_creator}> Gerenciador de Formulários </h2> diff --git a/src/contexts/useForm.js b/src/contexts/useForm.js index 3d0bdbf40bd6b633b90e920715ad7d6935a30168..03c0d60ab8c144be115b386d7de5659d7a89682e 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"; @@ -238,7 +238,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 +248,13 @@ const useForm = () => { "question", "description", "options", - "subformId", + "subformId" ]) !== JSON.stringify(form[j], [ "question", "description", "options", - "subformId", + "subformId" ]) || differentValidation(backForm[i], form[j]) ) { @@ -279,14 +279,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) { - if (!error.response) + .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); @@ -304,13 +307,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) { - if (!error.response) alert("Seu formulário foi criado com sucesso."); + .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."); }); } @@ -336,7 +343,7 @@ const useForm = () => { setValidationValue, removeValidation, onDragEnd, - submit, + submit }; };