Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
f0e4335a
Commit
f0e4335a
authored
Jul 18, 2022
by
Lee SeoYeon
Browse files
SurveyForm Page
parent
f067e7f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/commons/SurveyForm.tsx
View file @
f0e4335a
import
React
,
{
InputHTMLAttributes
}
from
"
react
"
;
import
{
ACheckboxForm
}
from
"
./ACheckbox
"
;
import
{
ADropdownForm
}
from
"
./ADropdown
"
;
import
{
AEssayForm
}
from
"
./AEssayForm
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
import
{
SurveyType
}
from
"
../types
"
;
import
{
AQuestion
}
from
"
./AQuestion
"
;
import
{
ARadioForm
}
from
"
./ARadioForm
"
;
export
const
SurveyForm
=
()
=>
{
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
const
[
error
,
setError
]
=
useState
(
""
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
,
user
:
{},
title
:
""
,
comment
:
""
,
questions
:
[],
});
useEffect
(()
=>
{
ansSurvey
();
},
[
surveyId
]);
async
function
ansSurvey
()
{
try
{
if
(
surveyId
)
{
const
answersurvey
:
SurveyType
=
await
surveyApi
.
ansSurvey
(
surveyId
);
console
.
log
(
answersurvey
);
setSurvey
(
answersurvey
);
setSuccess
(
true
);
setError
(
""
);
}
else
{
setLoading
(
true
);
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
finally
{
setLoading
(
false
);
}
}
return
(
<
div
className
=
"flex flex-col place-items-center"
>
<
div
className
=
"flex flex-col container place-items-center mt-4"
>
<
form
className
=
"font-bold text-4xl text-center m-2"
>
설문지 제목
</
form
>
<
textarea
className
=
"font-bold text-1xl text-center m-2 resize-none"
placeholder
=
"설문조사에 대한 설명을 입력해주세요"
rows
=
{
2
}
cols
=
{
60
}
></
textarea
>
{
/* <ACheckboxForm></ACheckboxForm> */
}
<
ADropdownForm
></
ADropdownForm
>
<
AEssayForm
></
AEssayForm
>
<
ARadioForm
></
ARadioForm
>
<
p
className
=
"font-bold text-4xl text-center m-2"
>
{
survey
.
title
}
</
p
>
<
p
className
=
"font-bold text-1xl text-center m-2"
>
{
survey
.
comment
}
</
p
>
{
survey
.
questions
.
map
((
question
)
=>
{
return
<
AQuestion
question
=
{
question
}
></
AQuestion
>;
})
}
<
div
>
<
button
className
=
"rounded bg-themeColor my-5 py-2 px-5 font-bold text-white"
>
제출하기
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment