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
56d0596c
Commit
56d0596c
authored
Jul 26, 2022
by
Yoon, Daeki
😅
Browse files
아코디언 트랜지션 시간 짧게 변경 및 키 지정 및 answers 없을 때 버그 고침
parent
2b2a0917
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/survey/Accordion.tsx
View file @
56d0596c
...
...
@@ -3,28 +3,18 @@ import { baseImageUrl } from "../apis";
import
{
BasicQuestionType
}
from
"
../types
"
;
type
AccordionProps
=
{
question
:
any
;
question
:
BasicQuestionType
;
};
const
Accordion
=
({
question
}:
AccordionProps
)
=>
{
const
[
isOpened
,
setOpened
]
=
useState
<
boolean
>
(
false
);
const
[
height
,
setHeight
]
=
useState
<
string
>
(
"
0px
"
);
const
contentElement
=
useRef
<
HTMLDivElement
>
(
null
);
// useEffect(() => {
// if (question.type === "file") {
// getFiles();
// }
// }, []);
// async function getFiles() {
// try {
// } catch (error) {}
// }
const
HandleOpening
=
()
=>
{
setOpened
(
!
isOpened
);
setHeight
(
!
isOpened
?
`
${
contentElement
.
current
?.
scrollHeight
}
px`
:
"
0px
"
);
};
return
(
<
div
className
=
"p-1"
>
<
div
onClick
=
{
HandleOpening
}
>
...
...
@@ -39,19 +29,22 @@ const Accordion = ({ question }: AccordionProps) => {
<
div
ref
=
{
contentElement
}
style
=
{
{
height
:
height
}
}
className
=
"bg-gray-100 overflow-hidden transition-all duration-
7
00"
className
=
"bg-gray-100 overflow-hidden transition-all duration-
3
00"
>
{
question
.
type
===
"
file
"
?
question
.
answers
.
map
((
answer
:
any
)
=>
(
<
img
key
=
{
answer
.
url
}
alt
=
"file"
src
=
{
`
${
baseImageUrl
}
/
${
answer
.
url
}
`
}
/>
))
:
question
.
answers
.
map
((
answer
:
any
)
=>
(
<
p
className
=
"p-4"
>
{
answer
}
</
p
>
))
}
{
question
.
answers
&&
(
question
.
type
===
"
file
"
?
question
.
answers
.
map
((
answer
:
any
)
=>
(
<
img
key
=
{
answer
.
url
}
alt
=
"file"
src
=
{
`
${
baseImageUrl
}
/
${
answer
.
url
}
`
}
/>
))
:
question
.
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
<
p
key
=
{
index
}
className
=
"p-4"
>
{
answer
}
</
p
>
)))
}
</
div
>
</
div
>
</
div
>
...
...
frontend/src/survey/ResultSurvey.tsx
View file @
56d0596c
...
...
@@ -17,6 +17,7 @@ export const ResultSurvey = () => {
comment
:
""
,
questions
:
[],
});
useEffect
(()
=>
{
getAnswers
();
},
[
surveyId
]);
...
...
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