Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-creator-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simmctic
form-creator
form-creator-ui
Merge requests
!51
Issue
#29
: User can't answer a form twice
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#29
: User can't answer a form twice
issue/29-Answer
into
development
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Richard Fernando Heise Ferreira
requested to merge
issue/29-Answer
into
development
4 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
closes
#29 (closed)
Signed-off-by: Richard Heise
rfhf19@inf.ufpr.br
0
0
Merge request reports
Compare
development
development (base)
and
latest version
latest version
1911b482
1 commit,
4 years ago
1 file
+
34
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/pages/AnswerForm.js
+
34
−
0
Options
@@ -153,6 +153,7 @@ function AnwserForm() {
const
res
=
await
api
.
post
(
`/answer/
${
id
}
`
,
backendTranslation
())
.
then
(
function
(
res
)
{
setCookie
(
"
answerForm
"
,
id
,
92
);
alert
(
"
Formulário respondido!
"
);
})
.
catch
(
error
=>
{
@@ -205,6 +206,7 @@ function AnwserForm() {
const
res
=
await
api
.
get
(
`/form/
${
id
}
`
)
.
then
(
function
(
res
)
{
checkCookie
(
id
);
setFormData
(
res
.
data
);
mapInputs
(
res
.
data
);
})
@@ -223,6 +225,38 @@ function AnwserForm() {
});
}
function
setCookie
(
cookieName
,
cookieValue
,
expirationsDays
)
{
var
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
expirationsDays
*
60
*
60
*
24
*
1000
);
var
expires
=
"
expires=
"
+
date
.
toUTCString
();
document
.
cookie
=
cookieName
+
"
=
"
+
cookieValue
+
"
;
"
+
expires
+
"
;path=/
"
;
}
function
getCookie
(
cookieName
)
{
var
name
=
cookieName
+
"
=
"
;
var
ca
=
document
.
cookie
.
split
(
"
;
"
);
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
)
{
var
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
"
"
)
{
c
=
c
.
substring
(
1
);
}
if
(
c
.
indexOf
(
name
)
==
0
)
{
return
c
.
substring
(
name
.
length
,
c
.
length
);
}
}
return
""
;
}
function
checkCookie
(
id
)
{
var
answer
=
getCookie
(
"
answerForm
"
);
if
(
answer
==
id
)
{
alert
(
"
Você já respondeu esse formulário!
"
);
let
path
=
`/signin`
;
history
.
push
(
path
);
}
}
/** First thing the page does is getting the form from the API. */
useEffect
(()
=>
{
getForm
(
id
);
Loading