Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
students
survey
Commits
7650280d
Commit
7650280d
authored
Jul 05, 2022
by
Jiwon Yoon
Browse files
Edit 버튼 생성
parent
8b54a1b3
Changes
5
Hide whitespace changes
Inline
Side-by-side
frontend/src/CreateSurveyForm/CreateSurveyFormPage.tsx
View file @
7650280d
...
@@ -118,6 +118,7 @@ const RatingQ: RatingType = {
...
@@ -118,6 +118,7 @@ const RatingQ: RatingType = {
};
};
export
const
CreateSurveyForm
=
()
=>
{
export
const
CreateSurveyForm
=
()
=>
{
const
[
currentId
,
setCurrentId
]
=
useState
<
string
>
(
""
);
const
[
questionList
,
setQuestionList
]
=
useState
<
Array
<
BasicQuestionType
>>
([
const
[
questionList
,
setQuestionList
]
=
useState
<
Array
<
BasicQuestionType
>>
([
EssayQ
,
EssayQ
,
RadioQ
,
RadioQ
,
...
@@ -125,11 +126,15 @@ export const CreateSurveyForm = () => {
...
@@ -125,11 +126,15 @@ export const CreateSurveyForm = () => {
]);
]);
const
[
survey
,
setSurvey
]
=
useState
();
const
[
survey
,
setSurvey
]
=
useState
();
function
changeCurrentId
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
):
void
{
setCurrentId
(
event
.
currentTarget
.
id
);
}
function
QuestionListChange
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
):
void
{
function
QuestionListChange
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
):
void
{
const
newList
:
BasicQuestionType
[]
=
[...
questionList
];
const
newList
:
BasicQuestionType
[]
=
[...
questionList
];
const
targetId
:
any
=
e
.
target
.
name
;
const
obj
:
any
=
newList
.
find
((
a
)
=>
a
.
id
===
e
.
target
.
id
);
//고유 _id로 질문찾기
const
obj
:
any
=
newList
.
find
((
a
)
=>
a
.
id
==
=
e
.
target
.
id
)
;
const
targetKey
:
any
=
e
.
target
.
name
;
obj
[
target
Id
]
=
e
.
target
.
value
;
obj
[
target
Key
]
=
e
.
target
.
value
;
setQuestionList
(
newList
);
setQuestionList
(
newList
);
}
}
...
@@ -157,30 +162,34 @@ export const CreateSurveyForm = () => {
...
@@ -157,30 +162,34 @@ export const CreateSurveyForm = () => {
function
deleteQuestion
():
void
{}
function
deleteQuestion
():
void
{}
return
(
return
(
<
div
className
=
"flex flex-col place-items-center"
>
<>
<
div
className
=
"flex flex-col container place-items-center mt-4"
>
{
console
.
log
(
currentId
)
}
<
input
<
div
className
=
"flex flex-col place-items-center"
>
type
=
"text"
<
div
className
=
"flex flex-col container place-items-center mt-4"
>
className
=
"font-bold text-4xl text-center m-2 border-b-2"
<
input
placeholder
=
"설문지 제목"
type
=
"text"
></
input
>
className
=
"font-bold text-4xl text-center m-2 border-b-2"
<
textarea
placeholder
=
"설문지 제목"
className
=
"font-bold text-1xl text-center m-2 resize-none"
></
input
>
placeholder
=
"설문조사에 대한 설명을 입력해주세요"
<
textarea
rows
=
{
2
}
className
=
"font-bold text-1xl text-center m-2 resize-none"
cols
=
{
60
}
placeholder
=
"설문조사에 대한 설명을 입력해주세요"
></
textarea
>
rows
=
{
2
}
</
div
>
cols
=
{
60
}
<
Question
></
textarea
>
questionList
=
{
questionList
}
</
div
>
QuestionListChange
=
{
QuestionListChange
}
<
Question
addQuestion
=
{
addQuestion
}
questionList
=
{
questionList
}
/>
QuestionListChange
=
{
QuestionListChange
}
<
div
>
addQuestion
=
{
addQuestion
}
<
button
className
=
"border bg-themeColor my-5 py-2 px-3 font-bold text-white"
>
changeCurrentId
=
{
changeCurrentId
}
설문조사 생성
/>
</
button
>
<
div
>
<
button
className
=
"border bg-themeColor my-5 py-2 px-3 font-bold text-white"
>
설문조사 생성
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
</>
);
);
};
};
frontend/src/CreateSurveyForm/Edit.tsx
0 → 100644
View file @
7650280d
import
React
from
"
react
"
;
type
Props
=
{
id
:
string
;
changeCurrentId
:
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
};
export
const
Edit
=
({
id
,
changeCurrentId
}:
Props
)
=>
{
return
(
<
button
id
=
{
id
}
className
=
""
onClick
=
{
changeCurrentId
}
>
수정
</
button
>
);
};
frontend/src/CreateSurveyForm/QEssay.tsx
View file @
7650280d
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
EssayType
}
from
"
./CreateSurveyFormPage
"
;
import
{
EssayType
}
from
"
./CreateSurveyFormPage
"
;
import
{
Edit
}
from
"
./Edit
"
;
type
Props
=
{
type
Props
=
{
element
:
EssayType
;
element
:
EssayType
;
QuestionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
QuestionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
changeCurrentId
:
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
};
};
export
const
QEssay
=
({
element
,
QuestionListChange
}:
Props
)
=>
{
export
const
QEssay
=
({
element
,
QuestionListChange
,
changeCurrentId
,
}:
Props
)
=>
{
return
(
return
(
<
div
className
=
"flex flex-col container w-4/5 h-auto border-2 border-themeColor items-center m-3 py-2"
>
<
div
className
=
"flex flex-col container w-4/5 h-auto border-2 border-themeColor items-center m-3 py-2"
>
<
div
className
=
"flex h-16 w-full place-content-between items-center"
>
<
div
className
=
"flex h-16 w-full place-content-between items-center"
>
...
@@ -52,6 +58,7 @@ export const QEssay = ({ element, QuestionListChange }: Props) => {
...
@@ -52,6 +58,7 @@ export const QEssay = ({ element, QuestionListChange }: Props) => {
<
button
className
=
"w-1/12"
>
필수
</
button
>
<
button
className
=
"w-1/12"
>
필수
</
button
>
<
button
className
=
"w-1/12"
>
옵션
</
button
>
<
button
className
=
"w-1/12"
>
옵션
</
button
>
<
button
className
=
"w-1/12"
>
삭제
</
button
>
<
button
className
=
"w-1/12"
>
삭제
</
button
>
<
Edit
id
=
{
element
.
id
}
changeCurrentId
=
{
changeCurrentId
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
...
...
frontend/src/CreateSurveyForm/QRadio.tsx
View file @
7650280d
...
@@ -44,12 +44,19 @@ export const QRadio = ({ element, QuestionListChange }: Props) => (
...
@@ -44,12 +44,19 @@ export const QRadio = ({ element, QuestionListChange }: Props) => (
></
input
>
></
input
>
</
div
>
</
div
>
<
div
className
=
"flex mt-4"
>
<
div
className
=
"flex mt-4"
>
{
element
.
content
.
choices
.
map
((
e
:
string
)
=>
(
{
element
.
content
.
choices
.
map
((
e
:
string
,
index
:
number
)
=>
(
<
div
>
<
div
>
<
input
type
=
"radio"
id
=
{
e
}
name
=
"choice"
value
=
{
e
}
checked
=
{
false
}
/>
<
input
type
=
"radio"
id
=
{
element
.
id
}
name
=
"choice"
value
=
{
e
}
disabled
/>
<
input
<
input
type
=
"text"
type
=
"text"
name
=
"content"
name
=
{
"
choice
"
+
`
${
index
}
`
}
// key={`${index}`}
className
=
"mx-2 border-b-2"
className
=
"mx-2 border-b-2"
placeholder
=
{
e
}
placeholder
=
{
e
}
onChange
=
{
QuestionListChange
}
onChange
=
{
QuestionListChange
}
...
...
frontend/src/CreateSurveyForm/Question.tsx
View file @
7650280d
...
@@ -11,12 +11,14 @@ type Props = {
...
@@ -11,12 +11,14 @@ type Props = {
questionList
:
BasicQuestionType
[];
questionList
:
BasicQuestionType
[];
QuestionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
QuestionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
addQuestion
:
()
=>
void
;
addQuestion
:
()
=>
void
;
changeCurrentId
:
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
};
};
export
const
Question
=
({
export
const
Question
=
({
questionList
,
questionList
,
QuestionListChange
,
QuestionListChange
,
addQuestion
,
addQuestion
,
changeCurrentId
,
}:
Props
)
=>
{
}:
Props
)
=>
{
return
(
return
(
<>
<>
...
@@ -28,6 +30,7 @@ export const Question = ({
...
@@ -28,6 +30,7 @@ export const Question = ({
<
QEssay
<
QEssay
element
=
{
element
}
element
=
{
element
}
QuestionListChange
=
{
QuestionListChange
}
QuestionListChange
=
{
QuestionListChange
}
changeCurrentId
=
{
changeCurrentId
}
/>
/>
);
);
case
"
radio
"
:
case
"
radio
"
:
...
...
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