Skip to content
Snippets Groups Projects
Commit 8e67bd52 authored by Stephanie Briere Americo's avatar Stephanie Briere Americo
Browse files

Merge branch 'issue/30' into 'development'

Issue #30: Add redirects and adjusting others

See merge request !32
parents 606d8a1d 14e0bc39
No related branches found
No related tags found
3 merge requests!58Version 1.1,!54Issue #53: Fix password info,!32Issue #30: Add redirects and adjusting others
...@@ -109,7 +109,11 @@ export default function Header() { ...@@ -109,7 +109,11 @@ export default function Header() {
</Grid> </Grid>
</Grid> </Grid>
<Grid container item xs={6} sm={6} md={4} justify="center"> <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}> <h2 className={classes.form_creator}>
Gerenciador de Formulários Gerenciador de Formulários
</h2> </h2>
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
selectOptionsTesting, selectOptionsTesting,
testSubformSchema, testSubformSchema,
selectOptionTextTesting, selectOptionTextTesting,
testTextValidation, testTextValidation
} from "../components/fieldsDisplayForm/utils/schemas"; } from "../components/fieldsDisplayForm/utils/schemas";
import { import {
pushTitle, pushTitle,
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
pushSelect, pushSelect,
pushRadio, pushRadio,
pushCheckbox, pushCheckbox,
pushSubform, pushSubform
} from "../components/fieldsDisplayForm/utils/FormComposition"; } from "../components/fieldsDisplayForm/utils/FormComposition";
import api from "../api"; import api from "../api";
...@@ -238,7 +238,7 @@ const useForm = () => { ...@@ -238,7 +238,7 @@ const useForm = () => {
*/ */
async function setId() { async function setId() {
const fetchData = async () => { 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); let backForm = createFrontendForm(res.data);
for (let i = 1; i < backForm.length; i++) { for (let i = 1; i < backForm.length; i++) {
for (let j = 1; j < form.length; j++) { for (let j = 1; j < form.length; j++) {
...@@ -248,13 +248,13 @@ const useForm = () => { ...@@ -248,13 +248,13 @@ const useForm = () => {
"question", "question",
"description", "description",
"options", "options",
"subformId", "subformId"
]) !== ]) !==
JSON.stringify(form[j], [ JSON.stringify(form[j], [
"question", "question",
"description", "description",
"options", "options",
"subformId", "subformId"
]) || ]) ||
differentValidation(backForm[i], form[j]) differentValidation(backForm[i], form[j])
) { ) {
...@@ -279,14 +279,17 @@ const useForm = () => { ...@@ -279,14 +279,17 @@ const useForm = () => {
const post_response = await api const post_response = await api
.put(`/form/${routeId}`, data, { .put(`/form/${routeId}`, data, {
headers: { headers: {
authorization: `bearer ${window.sessionStorage.getItem("token")}`, authorization: `bearer ${window.sessionStorage.getItem("token")}`
}, }
}) })
.then(function (error) { .then(function(error) {
if (!error.response) if (!error.response) {
alert("Seu formulário foi atualizado com sucesso."); 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) { if (error.response.status === 401) {
let path = `/signin`; let path = `/signin`;
history.push(path); history.push(path);
...@@ -304,13 +307,17 @@ const useForm = () => { ...@@ -304,13 +307,17 @@ const useForm = () => {
const post_response = await api const post_response = await api
.post(`/form`, await createBackendForm(form), { .post(`/form`, await createBackendForm(form), {
headers: { 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."); 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."); alert("Um erro ocorreu.");
}); });
} }
...@@ -336,7 +343,7 @@ const useForm = () => { ...@@ -336,7 +343,7 @@ const useForm = () => {
setValidationValue, setValidationValue,
removeValidation, removeValidation,
onDragEnd, onDragEnd,
submit, submit
}; };
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment