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
d24ccceb
Commit
d24ccceb
authored
Jul 02, 2022
by
Jiwon Yoon
Browse files
onChange함수, UI수정
parent
9a60dc8a
Changes
9
Hide whitespace changes
Inline
Side-by-side
frontend/src/CreateSurveyForm/Q
_
Assay.tsx
→
frontend/src/CreateSurveyForm/QAssay.tsx
View file @
d24ccceb
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
EssayType
,
BasicQuestionType
}
from
"
./Question
"
;
import
{
EssayType
}
from
"
./Question
"
;
type
Props
=
{
type
Props
=
{
element
:
EssayType
;
element
:
EssayType
;
q
uestionList
:
BasicQuestionType
[]
;
Q
uestionList
Change
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
};
};
export
const
Q_Assay
=
({
element
,
questionList
}:
Props
)
=>
{
export
const
QAssay
=
({
element
,
QuestionListChange
}:
Props
)
=>
{
console
.
log
(
questionList
);
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"
>
<
p
className
=
"text-xl font-bold ml-6 border-b-2"
>
<
input
<
input
type
=
"text"
placeholder
=
{
element
.
title
}
></
input
>
type
=
"text"
</
p
>
name
=
{
element
.
name
}
id
=
"title"
className
=
"text-xl font-bold ml-6 border-b-2 w-1/2"
placeholder
=
{
element
.
title
}
onChange
=
{
QuestionListChange
}
></
input
>
<
select
<
select
id
=
"Questions"
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
...
@@ -30,16 +34,18 @@ export const Q_Assay = ({ element, questionList }: Props) => {
...
@@ -30,16 +34,18 @@ export const Q_Assay = ({ element, questionList }: Props) => {
<
option
value
=
"Date"
>
날짜
</
option
>
<
option
value
=
"Date"
>
날짜
</
option
>
</
select
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full"
>
<
div
className
=
"flex w-full justify-center"
>
<
textarea
<
input
className
=
"border"
type
=
"text"
rows
=
{
1
}
name
=
{
element
.
name
}
cols
=
{
80
}
id
=
"comment"
className
=
"border w-11/12"
placeholder
=
"질문에 대한 설명을 입력해주세요"
placeholder
=
"질문에 대한 설명을 입력해주세요"
></
textarea
>
onChange
=
{
QuestionListChange
}
></
input
>
</
div
>
</
div
>
<
div
id
=
"commentarea"
className
=
"flex
border mt-4
"
>
<
div
id
=
"commentarea"
className
=
"flex
mt-4 w-full justify-center
"
>
<
textarea
className
=
"
resize-none"
readOnly
></
textarea
>
<
input
className
=
"
border w-11/12 h-16"
disabled
></
input
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-end py-2"
>
<
div
className
=
"flex w-full justify-end py-2"
>
<
button
className
=
"w-1/12"
>
필수
</
button
>
<
button
className
=
"w-1/12"
>
필수
</
button
>
...
...
frontend/src/CreateSurveyForm/Q
_
Checkbox.tsx
→
frontend/src/CreateSurveyForm/QCheckbox.tsx
View file @
d24ccceb
...
@@ -5,7 +5,7 @@ type Props = {
...
@@ -5,7 +5,7 @@ type Props = {
element
:
CheckboxType
;
element
:
CheckboxType
;
};
};
export
const
Q
_
Checkbox
=
({
element
}:
Props
)
=>
(
export
const
QCheckbox
=
({
element
}:
Props
)
=>
(
<
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 flexgi-row h-16 w-full place-content-between items-center"
>
<
div
className
=
"flex flexgi-row h-16 w-full place-content-between items-center"
>
<
p
className
=
"text-xl font-bold ml-6 border-b-2"
>
<
p
className
=
"text-xl font-bold ml-6 border-b-2"
>
...
...
frontend/src/CreateSurveyForm/Q
_
Date.tsx
→
frontend/src/CreateSurveyForm/QDate.tsx
View file @
d24ccceb
File moved
frontend/src/CreateSurveyForm/Q
_
Dropdown.tsx
→
frontend/src/CreateSurveyForm/QDropdown.tsx
View file @
d24ccceb
File moved
frontend/src/CreateSurveyForm/Q
_
File.tsx
→
frontend/src/CreateSurveyForm/QFile.tsx
View file @
d24ccceb
File moved
frontend/src/CreateSurveyForm/Q
_
Matrix.tsx
→
frontend/src/CreateSurveyForm/QMatrix.tsx
View file @
d24ccceb
File moved
frontend/src/CreateSurveyForm/Q
_
Radio.tsx
→
frontend/src/CreateSurveyForm/QRadio.tsx
View file @
d24ccceb
...
@@ -3,14 +3,20 @@ import { RadioType } from "./Question";
...
@@ -3,14 +3,20 @@ import { RadioType } from "./Question";
type
Props
=
{
type
Props
=
{
element
:
RadioType
;
element
:
RadioType
;
QuestionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
};
};
export
const
Q
_
Radio
=
({
element
}:
Props
)
=>
(
export
const
QRadio
=
({
element
,
QuestionListChange
}:
Props
)
=>
(
<
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 flexgi-row h-16 w-full place-content-between items-center"
>
<
div
className
=
"flex h-16 w-full place-content-between items-center"
>
<
p
className
=
"text-xl font-bold ml-6 border-b-2"
>
<
input
<
input
type
=
"text "
placeholder
=
{
element
.
title
}
></
input
>
type
=
"text"
</
p
>
name
=
{
element
.
name
}
id
=
"title"
className
=
"text-xl font-bold ml-6 border-b-2 w-1/2"
placeholder
=
{
element
.
title
}
onChange
=
{
QuestionListChange
}
></
input
>
<
select
<
select
id
=
"Questions"
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor focus:themeColor block w-full mr-3 p-2.5"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor focus:themeColor block w-full mr-3 p-2.5"
...
@@ -27,22 +33,26 @@ export const Q_Radio = ({ element }: Props) => (
...
@@ -27,22 +33,26 @@ export const Q_Radio = ({ element }: Props) => (
<
option
value
=
"Date"
>
날짜
</
option
>
<
option
value
=
"Date"
>
날짜
</
option
>
</
select
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex "
>
<
div
className
=
"flex w-full justify-center"
>
<
textarea
<
input
className
=
"border"
type
=
"text"
rows
=
{
1
}
name
=
{
element
.
name
}
cols
=
{
80
}
id
=
"comment"
className
=
"border w-11/12"
placeholder
=
"질문에 대한 설명을 입력해주세요"
placeholder
=
"질문에 대한 설명을 입력해주세요"
></
textarea
>
onChange
=
{
QuestionListChange
}
></
input
>
</
div
>
</
div
>
<
div
id
=
"commentarea"
className
=
"flex mt-4"
>
<
div
className
=
"flex mt-4"
>
{
element
.
content
.
choices
.
map
((
e
:
string
)
=>
(
{
element
.
content
.
choices
.
map
((
e
:
string
)
=>
(
<
div
>
<
div
>
<
input
type
=
"radio"
id
=
{
e
}
name
=
"choice"
value
=
{
e
}
checked
=
{
false
}
/>
<
input
type
=
"radio"
id
=
{
e
}
name
=
"choice"
value
=
{
e
}
checked
=
{
false
}
/>
<
input
<
input
type
=
"text"
type
=
"text"
name
=
"content"
className
=
"mx-2 border-b-2"
className
=
"mx-2 border-b-2"
placeholder
=
{
e
}
placeholder
=
{
e
}
onChange
=
{
QuestionListChange
}
></
input
>
></
input
>
<
button
></
button
>
<
button
></
button
>
</
div
>
</
div
>
...
...
frontend/src/CreateSurveyForm/Q
_
Rating.tsx
→
frontend/src/CreateSurveyForm/QRating.tsx
View file @
d24ccceb
File moved
frontend/src/CreateSurveyForm/Question.tsx
View file @
d24ccceb
import
React
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
Q
_
Assay
}
from
"
./Q
_
Assay
"
;
import
{
QAssay
}
from
"
./QAssay
"
;
import
{
Q
_
Checkbox
}
from
"
./Q
_
Checkbox
"
;
import
{
QCheckbox
}
from
"
./QCheckbox
"
;
import
{
Q
_
Radio
}
from
"
./Q
_
Radio
"
;
import
{
QRadio
}
from
"
./QRadio
"
;
export
interface
BasicQuestionType
{
export
interface
BasicQuestionType
{
type
:
string
;
type
:
string
;
name
:
string
;
name
:
string
;
title
:
string
;
title
:
string
;
isRequired
:
boolean
;
isRequired
:
boolean
;
comment
:
string
;
content
:
any
;
content
:
any
;
[
key
:
string
]:
string
|
number
|
boolean
|
any
;
}
}
export
interface
EssayType
extends
BasicQuestionType
{}
export
interface
EssayType
extends
BasicQuestionType
{}
let
EssayQ
:
EssayType
=
{
type
:
"
assay
"
,
name
:
"
Question1
"
,
title
:
"
Question1
"
,
isRequired
:
false
,
content
:
null
,
};
export
interface
RadioType
extends
BasicQuestionType
{
export
interface
RadioType
extends
BasicQuestionType
{
content
:
{
content
:
{
hasOther
:
boolean
;
hasOther
:
boolean
;
...
@@ -27,47 +20,96 @@ export interface RadioType extends BasicQuestionType {
...
@@ -27,47 +20,96 @@ export interface RadioType extends BasicQuestionType {
otherText
:
string
;
otherText
:
string
;
};
};
}
}
let
RadioQ
:
RadioType
=
{
export
interface
CheckboxType
extends
BasicQuestionType
{
content
:
{
choices
:
any
[];
maxCount
:
number
;
};
}
const
EssayQ
:
EssayType
=
{
type
:
"
assay
"
,
name
:
"
Question1
"
,
title
:
"
Question1
"
,
isRequired
:
false
,
comment
:
"
질문에 대한 설명을 입력해주세요
"
,
content
:
null
,
};
const
RadioQ
:
RadioType
=
{
type
:
"
radio
"
,
type
:
"
radio
"
,
name
:
"
Question2
"
,
name
:
"
Question2
"
,
title
:
"
Question2
"
,
title
:
"
Question2
"
,
isRequired
:
false
,
isRequired
:
false
,
comment
:
"
질문에 대한 설명을 입력해주세요
"
,
content
:
{
content
:
{
hasOther
:
false
,
hasOther
:
false
,
otherText
:
""
,
otherText
:
""
,
choices
:
[
"
1
"
,
"
2
"
,
"
3
"
],
choices
:
[
"
1
"
,
"
2
"
,
"
3
"
],
},
},
};
};
const
CheckboxQ
:
CheckboxType
=
{
export
interface
CheckboxType
extends
BasicQuestionType
{
content
:
{
choices
:
any
[];
maxCount
:
number
;
};
}
let
CheckboxQ
:
CheckboxType
=
{
type
:
"
checkbox
"
,
type
:
"
checkbox
"
,
name
:
"
Question3
"
,
name
:
"
Question3
"
,
title
:
"
Question3
"
,
title
:
"
Question3
"
,
isRequired
:
false
,
isRequired
:
false
,
comment
:
"
질문에 대한 설명을 입력해주세요
"
,
content
:
{
content
:
{
choices
:
[
"
ch1
"
,
"
ch2
"
,
"
ch3
"
],
choices
:
[
"
ch1
"
,
"
ch2
"
,
"
ch3
"
],
maxCount
:
2
,
maxCount
:
2
,
},
},
};
};
le
t
questionList
:
BasicQuestionType
[]
=
[
EssayQ
,
RadioQ
,
CheckboxQ
];
// cons
t questionList: BasicQuestionType[] = [EssayQ, RadioQ, CheckboxQ];
export
const
Question
=
()
=>
(
export
const
Question
=
()
=>
{
<>
const
[
questionList
,
setQuestionList
]
=
useState
<
BasicQuestionType
[]
>
([
{
questionList
.
map
((
element
)
=>
{
EssayQ
,
if
(
element
.
type
===
"
assay
"
)
{
RadioQ
,
return
<
Q_Assay
questionList
=
{
questionList
}
element
=
{
element
}
/>;
]);
}
else
if
(
element
.
type
===
"
radio
"
)
{
// const [survey, setSurvey] = useState();
return
<
Q_Radio
element
=
{
element
}
/>;
}
else
if
(
element
.
type
===
"
checkbox
"
)
{
function
QuestionListChange
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
):
void
{
return
<
Q_Checkbox
element
=
{
element
}
/>;
const
newList
:
BasicQuestionType
[]
=
[...
questionList
];
}
const
targetId
:
any
=
e
.
target
.
id
;
})
}
const
obj
:
any
=
newList
.
find
((
a
)
=>
a
.
name
===
e
.
target
.
name
);
</>
obj
[
targetId
]
=
e
.
target
.
value
;
);
setQuestionList
(
newList
);
}
return
(
<>
{
console
.
log
(
questionList
)
}
{
questionList
.
map
((
element
)
=>
{
switch
(
element
.
type
)
{
case
"
assay
"
:
return
(
<
QAssay
element
=
{
element
}
QuestionListChange
=
{
QuestionListChange
}
/>
);
case
"
radio
"
:
return
(
<
QRadio
element
=
{
element
}
QuestionListChange
=
{
QuestionListChange
}
/>
);
case
"
checkbox
"
:
return
<
QCheckbox
element
=
{
element
}
/>;
default
:
break
;
}
// if (element.type === "assay") {
// return (
// <QAssay element={element} QuestionListChange={QuestionListChange} />
// );
// } else if (element.type === "radio") {
// return <QRadio element={element} />;
// } else if (element.type === "checkbox") {
// return <QCheckbox element={element} />;
// }
})
}
</>
);
};
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