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
514ebfde
Commit
514ebfde
authored
Jan 11, 2023
by
jang dong hyeok
Browse files
순서 수정
parent
4e580901
Changes
1
Show whitespace changes
Inline
Side-by-side
frontend/src/surveys/Question.tsx
View file @
514ebfde
...
@@ -22,39 +22,7 @@ export const Question = ({
...
@@ -22,39 +22,7 @@ export const Question = ({
}:
IQuestionProps
)
=>
{
}:
IQuestionProps
)
=>
{
const
[
question
,
setQuestion
]
=
useState
(
element
);
const
[
question
,
setQuestion
]
=
useState
(
element
);
const
isEditing
=
question
.
isEditing
;
const
isEditing
=
question
.
isEditing
;
//
const
[{
isDragging
},
drag
]
=
useDrag
(()
=>
({
type
:
SurveyLayout
.
name
,
item
:
{
name
:
question
.
type
},
end
:
(
item
,
monitor
)
=>
{
const
dropResult
=
monitor
.
getDropResult
<
DropResult
>
();
if
(
item
&&
dropResult
)
{
alert
(
`You dropped
${
item
.
name
}
`
);
}
},
collect
:
(
monitor
)
=>
({
isDragging
:
monitor
.
isDragging
(),
handlerId
:
monitor
.
getHandlerId
(),
}),
}));
const
[{
canDrop
,
isOver
},
drop
]
=
useDrop
(()
=>
({
accept
:
SurveyLayout
.
name
,
collect
:
(
monitor
)
=>
({
isOver
:
monitor
.
isOver
(),
canDrop
:
monitor
.
canDrop
(),
}),
}));
const
isActive
=
canDrop
&&
isOver
;
let
backgroundColor
=
"
#222
"
;
if
(
isActive
)
{
backgroundColor
=
"
darkgreen
"
;
}
else
if
(
canDrop
)
{
backgroundColor
=
"
darkkhaki
"
;
}
//
async
function
handleEditComplete
()
{
async
function
handleEditComplete
()
{
question
.
content
.
choices
.
map
((
choice
)
=>
{
question
.
content
.
choices
.
map
((
choice
)
=>
{
if
(
choice
.
text
.
trim
()
===
""
)
{
if
(
choice
.
text
.
trim
()
===
""
)
{
...
@@ -107,9 +75,39 @@ export const Question = ({
...
@@ -107,9 +75,39 @@ export const Question = ({
setQuestion
({
...
question
,
isEditing
:
true
});
setQuestion
({
...
question
,
isEditing
:
true
});
handleQuestion
({
...
question
,
isEditing
:
true
});
handleQuestion
({
...
question
,
isEditing
:
true
});
};
};
//
const
[{
isDragging
},
drag
]
=
useDrag
(()
=>
({
type
:
SurveyLayout
.
name
,
item
:
{
name
:
question
.
type
},
end
:
(
item
,
monitor
)
=>
{
const
dropResult
=
monitor
.
getDropResult
<
DropResult
>
();
if
(
item
&&
dropResult
)
{
alert
(
`You dropped
${
item
.
name
}
`
);
}
},
collect
:
(
monitor
)
=>
({
isDragging
:
monitor
.
isDragging
(),
handlerId
:
monitor
.
getHandlerId
(),
}),
}));
const
[{
canDrop
,
isOver
},
drop
]
=
useDrop
(()
=>
({
accept
:
SurveyLayout
.
name
,
collect
:
(
monitor
)
=>
({
isOver
:
monitor
.
isOver
(),
canDrop
:
monitor
.
canDrop
(),
}),
hover
(
item
,
monitor
)
{
if
(
!
isDragging
)
{
return
;
}
},
}));
//
return
(
return
(
<
div
ref
=
{
drop
}
className
=
"flex w-
3/5
h-full justify-center"
>
<
div
ref
=
{
drop
}
className
=
"flex w-
full
h-full justify-center"
>
<
div
<
div
ref
=
{
drag
}
ref
=
{
drag
}
style
=
{
{
borderColor
:
isEditing
?
"
red
"
:
"
#0A8A8A
"
}
}
style
=
{
{
borderColor
:
isEditing
?
"
red
"
:
"
#0A8A8A
"
}
}
...
...
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