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
c4dd6b9e
Commit
c4dd6b9e
authored
Sep 19, 2022
by
Jiwon Yoon
Browse files
isEditing, SurveyLayout navLink style 수정
parent
beb1fdf0
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/layouts/SurveyLayout.tsx
View file @
c4dd6b9e
...
...
@@ -2,14 +2,19 @@ import React from "react";
import
{
NavLink
,
useOutletContext
}
from
"
react-router-dom
"
;
import
{
Outlet
,
useNavigate
,
useParams
}
from
"
react-router-dom
"
;
import
{
useSurveys
}
from
"
./SurveysLayout
"
;
import
type
{
CreateQuestionData
,
ICreateSurvey
,
ISurvey
}
from
"
../types
"
;
import
type
{
CreateQuestionData
,
ICreateSurvey
,
IQuestionData
,
ISurvey
,
}
from
"
../types
"
;
import
{
SpinnerIcon
}
from
"
../icons
"
;
import
{
surveyApi
}
from
"
../apis
"
;
type
SurveyContextType
=
{
survey
:
ICreateSurvey
;
update
:
(
survey
:
ISurvey
)
=>
Promise
<
any
>
;
createQuestion
:
(
question
:
Create
QuestionData
)
=>
Promise
<
any
>
;
createQuestion
:
(
question
:
I
QuestionData
)
=>
Promise
<
any
>
;
removeQuestion
:
(
questionId
:
string
)
=>
Promise
<
any
>
;
updateQuestion
:
(
question
:
CreateQuestionData
)
=>
Promise
<
any
>
;
};
...
...
@@ -17,7 +22,7 @@ type SurveyContextType = {
const
activeStyle
=
"
w-36 h-12 flex justify-center items-center bg-themeColor p-1 text-white text-center font-bold text-xl
"
;
const
inActiveStyle
=
"
w-36 h-12 flex justify-center items-center bg-white border border-themeColor p-1 text-center font-bold text-xl
"
;
"
w-36 h-12 flex justify-center items-center bg-white border border-themeColor
first:border-r-0 last:border-l-0
p-1 text-center font-bold text-xl
"
;
export
const
SurveyLayout
=
()
=>
{
const
{
surveys
,
update
,
updateLocalSurveysList
}
=
useSurveys
();
...
...
@@ -34,10 +39,10 @@ export const SurveyLayout = () => {
);
}
const
createQuestion
=
async
(
question
:
Create
QuestionData
)
=>
{
const
createQuestion
=
async
(
question
:
I
QuestionData
)
=>
{
const
newQuestion
=
await
surveyApi
.
addQuestion
(
survey
.
_id
!
,
question
);
console
.
log
(
"
new question:
"
,
newQuestion
);
newQuestion
.
isEditing
=
true
;
survey
.
questions
.
push
(
newQuestion
);
updateLocalSurveysList
(
survey
);
};
...
...
@@ -72,21 +77,21 @@ export const SurveyLayout = () => {
<
div
>
<
div
className
=
"flex justify-center items-center mt-6"
>
<
NavLink
to
=
{
`/surveys/
${
surveyId
}
`
}
end
=
{
true
}
to
=
{
`/surveys/
${
surveyId
}
/edit`
}
className
=
{
({
isActive
})
=>
isActive
?
activeStyle
+
"
rounded-l-3xl
"
:
inActiveStyle
+
"
rounded-l-3xl
"
}
>
설문
미리보기
설문
지 수정
</
NavLink
>
<
NavLink
to
=
{
`/surveys/
${
surveyId
}
/edit`
}
to
=
{
`/surveys/
${
surveyId
}
`
}
end
=
{
true
}
className
=
{
({
isActive
})
=>
(
isActive
?
activeStyle
:
inActiveStyle
)
}
>
설문
지 수정
설문
미리보기
</
NavLink
>
<
NavLink
to
=
{
`/surveys/
${
surveyId
}
/result`
}
...
...
frontend/src/surveys/EditSurvey.tsx
View file @
c4dd6b9e
...
...
@@ -50,14 +50,13 @@ export const EditSurvey = () => {
// };
const
addQuestion
=
async
()
=>
{
const
question
:
Create
QuestionData
=
{
const
question
:
I
QuestionData
=
{
order
:
questions
.
length
,
type
:
"
singletext
"
,
title
:
""
,
comment
:
""
,
isRequired
:
false
,
content
:
{
choices
:
[]
},
isEditing
:
true
,
};
// const updatedSurvey = await surveyApi.addQuestion(survey._id!, question);
await
createQuestion
(
question
);
...
...
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