Commit 5aef8193 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

update 수정

parent 96d0a352
......@@ -59,7 +59,10 @@ export const SurveyLayout = () => {
};
const updateQuestion = async (question: CreateQuestionData) => {
await surveyApi.updateQuestion(survey._id!, question);
const updatedQuestion = await surveyApi.updateQuestion(
survey._id!,
question
);
const questions = survey.questions;
const index = questions.findIndex((q) => q._id === question._id);
......
......@@ -65,6 +65,12 @@ export const getSurveys = asyncWrap(async (reqExp: Request, res: Response) => {
return res.json(surveys);
});
export const updateQuestion = asyncWrap(async (req: Request, res: Response) => {
const question = req.body;
const updatedQuestion = await questionDb.updateQuestion(question);
return res.json(updatedQuestion);
});
export const updateSurvey = asyncWrap(async (req, res) => {
const survey = req.body;
const updatedSurvey = await surveyDb.updateSurvey(survey);
......
......@@ -24,6 +24,7 @@ router
router
.route("/:surveyId/questions/:questionId")
.put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateQuestion)
.delete(
authCtrl.requireLogin,
authCtrl.authenticate,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment