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";
...
@@ -3,28 +3,18 @@ import { baseImageUrl } from "../apis";
import
{
BasicQuestionType
}
from
"
../types
"
;
import
{
BasicQuestionType
}
from
"
../types
"
;
type
AccordionProps
=
{
type
AccordionProps
=
{
question
:
any
;
question
:
BasicQuestionType
;
};
};
const
Accordion
=
({
question
}:
AccordionProps
)
=>
{
const
Accordion
=
({
question
}:
AccordionProps
)
=>
{
const
[
isOpened
,
setOpened
]
=
useState
<
boolean
>
(
false
);
const
[
isOpened
,
setOpened
]
=
useState
<
boolean
>
(
false
);
const
[
height
,
setHeight
]
=
useState
<
string
>
(
"
0px
"
);
const
[
height
,
setHeight
]
=
useState
<
string
>
(
"
0px
"
);
const
contentElement
=
useRef
<
HTMLDivElement
>
(
null
);
const
contentElement
=
useRef
<
HTMLDivElement
>
(
null
);
// useEffect(() => {
// if (question.type === "file") {
// getFiles();
// }
// }, []);
// async function getFiles() {
// try {
// } catch (error) {}
// }
const
HandleOpening
=
()
=>
{
const
HandleOpening
=
()
=>
{
setOpened
(
!
isOpened
);
setOpened
(
!
isOpened
);
setHeight
(
!
isOpened
?
`
${
contentElement
.
current
?.
scrollHeight
}
px`
:
"
0px
"
);
setHeight
(
!
isOpened
?
`
${
contentElement
.
current
?.
scrollHeight
}
px`
:
"
0px
"
);
};
};
return
(
return
(
<
div
className
=
"p-1"
>
<
div
className
=
"p-1"
>
<
div
onClick
=
{
HandleOpening
}
>
<
div
onClick
=
{
HandleOpening
}
>
...
@@ -39,19 +29,22 @@ const Accordion = ({ question }: AccordionProps) => {
...
@@ -39,19 +29,22 @@ const Accordion = ({ question }: AccordionProps) => {
<
div
<
div
ref
=
{
contentElement
}
ref
=
{
contentElement
}
style
=
{
{
height
:
height
}
}
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
&&
?
question
.
answers
.
map
((
answer
:
any
)
=>
(
(
question
.
type
===
"
file
"
<
img
?
question
.
answers
.
map
((
answer
:
any
)
=>
(
key
=
{
answer
.
url
}
<
img
alt
=
"file"
key
=
{
answer
.
url
}
src
=
{
`
${
baseImageUrl
}
/
${
answer
.
url
}
`
}
alt
=
"file"
/>
src
=
{
`
${
baseImageUrl
}
/
${
answer
.
url
}
`
}
))
/>
:
question
.
answers
.
map
((
answer
:
any
)
=>
(
))
<
p
className
=
"p-4"
>
{
answer
}
</
p
>
:
question
.
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
))
}
<
p
key
=
{
index
}
className
=
"p-4"
>
{
answer
}
</
p
>
)))
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
frontend/src/survey/ResultSurvey.tsx
View file @
56d0596c
...
@@ -17,6 +17,7 @@ export const ResultSurvey = () => {
...
@@ -17,6 +17,7 @@ export const ResultSurvey = () => {
comment
:
""
,
comment
:
""
,
questions
:
[],
questions
:
[],
});
});
useEffect
(()
=>
{
useEffect
(()
=>
{
getAnswers
();
getAnswers
();
},
[
surveyId
]);
},
[
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