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

update 수정

parent 96d0a352
...@@ -59,7 +59,10 @@ export const SurveyLayout = () => { ...@@ -59,7 +59,10 @@ export const SurveyLayout = () => {
}; };
const updateQuestion = async (question: CreateQuestionData) => { const updateQuestion = async (question: CreateQuestionData) => {
await surveyApi.updateQuestion(survey._id!, question); const updatedQuestion = await surveyApi.updateQuestion(
survey._id!,
question
);
const questions = survey.questions; const questions = survey.questions;
const index = questions.findIndex((q) => q._id === question._id); const index = questions.findIndex((q) => q._id === question._id);
......
...@@ -65,6 +65,12 @@ export const getSurveys = asyncWrap(async (reqExp: Request, res: Response) => { ...@@ -65,6 +65,12 @@ export const getSurveys = asyncWrap(async (reqExp: Request, res: Response) => {
return res.json(surveys); 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) => { export const updateSurvey = asyncWrap(async (req, res) => {
const survey = req.body; const survey = req.body;
const updatedSurvey = await surveyDb.updateSurvey(survey); const updatedSurvey = await surveyDb.updateSurvey(survey);
......
...@@ -24,6 +24,7 @@ router ...@@ -24,6 +24,7 @@ router
router router
.route("/:surveyId/questions/:questionId") .route("/:surveyId/questions/:questionId")
.put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateQuestion)
.delete( .delete(
authCtrl.requireLogin, authCtrl.requireLogin,
authCtrl.authenticate, 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