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
6442aa99
Commit
6442aa99
authored
Jul 23, 2022
by
Jiwon Yoon
Browse files
Merge branch '_seoyeon' into develop0722
parents
1b7b0a95
69e77b52
Changes
6
Hide whitespace changes
Inline
Side-by-side
frontend/src/commons/ADropdownForm.tsx
View file @
6442aa99
...
...
@@ -21,9 +21,9 @@ export const ADropdownForm = ({ element, answerQuestion }: Props) => {
console
.
log
(
answerQuestion
);
};
return
(
<
div
className
=
"flex flex-col container w-
4/5
h-auto
items-center
m-3 py-3"
>
<
div
className
=
"flex flex-col container w-
11/12
h-auto m-3 py-3"
>
<
select
className
=
"py-2 hover:bg-
themeColor bg-gray-200
rounded"
className
=
"py-2
w-48
hover:bg-
gray-200 border border-black
rounded"
onChange
=
{
handleChange
}
>
{
element
.
content
.
choices
.
map
((
choice
)
=>
(
...
...
frontend/src/commons/SurveyForm.tsx
View file @
6442aa99
import
React
,
{
FormEvent
,
useEffect
,
useRef
,
useState
}
from
"
react
"
;
import
{
Link
,
useNavigate
}
from
"
react-router-dom
"
;
import
{
useParams
}
from
"
react-router-dom
"
;
import
{
surveyApi
,
answerApi
}
from
"
../apis
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
...
...
@@ -13,6 +14,7 @@ export const SurveyForm = () => {
const
[
error
,
setError
]
=
useState
(
""
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
,
user
:
{},
...
...
@@ -32,6 +34,12 @@ export const SurveyForm = () => {
useEffect
(()
=>
{
ansSurvey
();
},
[
surveyId
]);
const
isSurvey
=
localStorage
.
getItem
(
`survey_
${
surveyId
}
`
);
if
(
isSurvey
)
{
console
.
log
(
"
object
"
,
isSurvey
);
alert
(
"
제출한 설문조사입니다
"
);
navigate
(
"
/
"
);
}
const
addFiles
=
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
{
if
(
!
files
.
find
((
a
)
=>
a
.
questionId
===
oneFile
.
questionId
))
{
...
...
@@ -82,6 +90,9 @@ export const SurveyForm = () => {
});
const
newAnswer
:
AnswerType
=
await
answerApi
.
saveAnswers
(
formData
);
console
.
log
(
newAnswer
);
localStorage
.
setItem
(
`survey_
${
surveyId
}
`
,
surveyId
??
""
);
alert
(
"
제출되었습니다
"
);
setSuccess
(
true
);
setError
(
""
);
}
catch
(
error
)
{
...
...
frontend/src/profile/MySurveyCard.tsx
View file @
6442aa99
...
...
@@ -16,7 +16,7 @@ export const MySurveyCard = ({ data }: Props) => {
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
editSurvey
=
()
=>
{
navigate
(
`/surveys/
${
data
.
_id
}
/edit
`
,
{
navigate
(
`/surveys/
edit/
${
data
.
_id
}
`
,
{
replace
:
true
,
state
:
{
save
:
true
},
});
...
...
frontend/src/survey/EditResultButton.tsx
View file @
6442aa99
...
...
@@ -17,7 +17,7 @@ export const EditResultButton = () => {
<
div
>
<
div
className
=
"flex place-content-center mt-6"
>
<
NavLink
to
=
{
`/surveys/
${
surveyId
}
/edit
`
}
to
=
{
`/surveys/
edit/
${
surveyId
}
`
}
style
=
{
({
isActive
})
=>
isActive
?
{
...
...
@@ -33,7 +33,7 @@ export const EditResultButton = () => {
<
div
className
=
"text-xl m-3 "
>
설문지 수정
</
div
>
</
NavLink
>
<
NavLink
to
=
{
`/surveys/
${
surveyId
}
/result`
}
to
=
{
`/surveys/
edit/
${
surveyId
}
/result`
}
style
=
{
({
isActive
})
=>
isActive
?
{
...
...
frontend/src/survey/EditSurvey.tsx
View file @
6442aa99
import
React
,
{
FormEvent
,
useEffect
,
useState
}
from
"
react
"
;
import
{
useParams
,
useLocation
}
from
"
react-router-dom
"
;
import
{
useParams
,
useLocation
,
useNavigate
}
from
"
react-router-dom
"
;
import
{
questionApi
,
surveyApi
}
from
"
../apis
"
;
import
{
SpinnerIcon
}
from
"
../icons
"
;
import
{
Question
}
from
"
../questions
"
;
...
...
@@ -20,6 +20,7 @@ export const EditSurvey = () => {
const
[
error
,
setError
]
=
useState
(
""
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
,
user
:
{},
...
...
@@ -60,6 +61,8 @@ export const EditSurvey = () => {
const
newSurvey
:
SurveyType
=
await
surveyApi
.
editSurvey
(
survey
);
console
.
log
(
newSurvey
);
setSuccess
(
true
);
alert
(
"
저장되었습니다
"
);
navigate
(
"
/profile
"
);
setError
(
""
);
}
catch
(
error
)
{
catchErrors
(
error
,
setError
);
...
...
src/controllers/survey.controller.ts
View file @
6442aa99
import
{
NextFunction
,
Request
,
Response
}
from
"
express
"
;
import
{
surveyDb
}
from
"
../db
"
;
import
{
asyncWrap
}
from
"
../helpers/asyncWrap
"
;
// import jwt, { JwtPayload } from "jsonwebtoken";
// import { cookieConfig, envConfig, jwtCofig } from "../config";
export
interface
TypedRequestAuth
<
T
>
extends
Request
{
auth
:
T
;
...
...
@@ -69,30 +67,4 @@ export const userBySurveyId = async (
error
.
message
||
"
설문조사를 작성한 사용자를 찾아내는 중 오류 발생
"
);
}
};
// export const checksurvey = asyncWrap(async(req, res)=> {
// const {_id} = req.body
// const surveyExist = await surveyDb.isSurvey(_id);
// if (surveyExist) {
// return res.status(422).send("이미 제출된 설문조사입니다")
// }
// });
// export const surveynotexist = asyncWrap(async (req, res) => {
// const { _id } = req.body;
// console.log(`surveyId: ${_id}`);
// const checksurveyId = await surveyDb.findUserBySurveyId(_id);
// const surveytoken = jwt.sign({existsurveyId: checksurveyId?.id}, jwtCofig.secret, {
// expiresIn:jwtCofig.expires,
// });
// res.cookie(cookieConfig.name, surveytoken, {
// maxAge:cookieConfig.maxAge,
// path:"/",
// httpOnly: envConfig.mode === "production",
// secure: envConfig.mode === "production",
// })
// res.json({
// surveyId: checksurveyId?._id
// })
// });
\ No newline at end of file
};
\ No newline at end of file
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