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
9cbfffe1
Commit
9cbfffe1
authored
Jul 25, 2022
by
Lee SeoYeon
Browse files
route 설정
parent
9e1cd4c9
Changes
4
Show whitespace changes
Inline
Side-by-side
frontend/src/profile/MySurveyCard.tsx
View file @
9cbfffe1
...
...
@@ -16,7 +16,7 @@ export const MySurveyCard = ({ data }: Props) => {
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
editSurvey
=
()
=>
{
navigate
(
`/surveys/
edit/
${
data
.
_id
}
`
,
{
navigate
(
`/surveys/
${
data
.
_id
}
/edit
`
,
{
replace
:
true
,
state
:
{
save
:
true
},
});
...
...
@@ -29,7 +29,7 @@ export const MySurveyCard = ({ data }: Props) => {
};
const
copyLink
=
()
=>
{
navigator
.
clipboard
.
writeText
(
`http://localhost:8080/survey
s
/
${
data
.
_id
}
`
);
navigator
.
clipboard
.
writeText
(
`http://localhost:8080/survey/
${
data
.
_id
}
`
);
alert
(
"
설문조사의 링크가 클립보드에 저장되었습니다.
"
);
};
...
...
frontend/src/survey/EditResultButton.tsx
View file @
9cbfffe1
...
...
@@ -17,7 +17,7 @@ export const EditResultButton = () => {
<
div
>
<
div
className
=
"flex place-content-center mt-6"
>
<
NavLink
to
=
{
`/surveys/
edit/
${
surveyId
}
`
}
to
=
{
`/surveys/
${
surveyId
}
/edit
`
}
style
=
{
({
isActive
})
=>
isActive
?
{
...
...
@@ -33,7 +33,7 @@ export const EditResultButton = () => {
<
div
className
=
"text-xl m-3 "
>
설문지 수정
</
div
>
</
NavLink
>
<
NavLink
to
=
{
`/surveys/
edit/
${
surveyId
}
/result`
}
to
=
{
`/surveys/
${
surveyId
}
/result`
}
style
=
{
({
isActive
})
=>
isActive
?
{
...
...
frontend/src/survey/ResultSurvey.tsx
View file @
9cbfffe1
import
React
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
surveyApi
}
from
"
../apis
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
import
{
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
Accordion
from
"
./Accordion
"
;
export
const
ResultSurvey
=
()
=>
{
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
const
[
error
,
setError
]
=
useState
(
""
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
||
""
,
user
:
{},
title
:
""
,
comment
:
""
,
questions
:
[],
});
useEffect
(()
=>
{
ansSurvey
();
},
[
surveyId
]);
async
function
ansSurvey
()
{
try
{
if
(
surveyId
)
{
const
getSurvey
:
any
=
await
surveyApi
.
ansSurvey
(
surveyId
);
console
.
log
(
"
survey가져옴ㅎㅎ
"
,
getSurvey
);
setSurvey
(
getSurvey
);
}
else
{
setLoading
(
true
);
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
}
finally
{
setLoading
(
false
);
}
}
const
data
=
[
{
title
:
"
1번질문
"
,
content
:
"
1번 답변들asdfadsgsjadhfasld;nvaldkfnbljgnahgvlajnbl janl;nvja; sabv;jnsvjl;asjvh asjfagkfnjf;nvasgn va;sdn va sglanksvl ds af adb adf afg dgafbg dfh jbvlkna lkslbk kjv nbkkdlfn akdl nvjbnkdjf nlkbakdn bkjnakjn n knk
"
,
content
:
"
1번 답변들
"
,
},
{
title
:
"
2번질문
"
,
...
...
@@ -21,10 +55,10 @@ export const ResultSurvey = () => {
<
div
className
=
"flex flex-col place-items-center"
>
<
div
className
=
"flex flex-col container place-items-center mt-4"
>
<
div
className
=
"font-bold text-4xl text-center m-2 border-b-2"
>
설문지 제목
{
survey
.
title
}
</
div
>
<
div
className
=
"font-bold text-1xl text-center m-2 resize-none"
>
설문조사 설명
{
survey
.
comment
}
</
div
>
</
div
>
...
...
src/controllers/survey.controller.ts
View file @
9cbfffe1
...
...
@@ -14,6 +14,7 @@ export const createSurvey = asyncWrap(
let
survey
=
req
.
body
;
survey
.
user
=
userId
;
console
.
log
(
"
survey body
"
,
survey
);
delete
survey
.
_id
;
const
newSurvey
=
await
surveyDb
.
createSurvey
(
survey
);
return
res
.
json
(
newSurvey
);
}
...
...
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