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

editing 상태 수정

parent dce3cbcd
......@@ -59,7 +59,7 @@ export const Question = ({
selectedType === "dropdown" ||
selectedType === "checkbox"
) {
element.content = {
content = {
choices: [{ text: "", value: 0 }],
};
} else if (selectedType === "essay") {
......
......@@ -94,17 +94,20 @@ export const CreateSurvey = () => {
async function addQuestion() {
try {
if (surveyId) {
const questions: BasicQuestionType[] = await questionApi.createQuestion(
// const questions: BasicQuestionType[] = await questionApi.createQuestion(
// surveyId
// );
// console.log(questions);
const question: BasicQuestionType = await questionApi.createQuestion(
surveyId
);
console.log(questions);
const addedEditing = questions.map((question) => {
return { qid: question._id, isEditing: false };
});
console.log("added editing", addedEditing);
setIsEditing([...addedEditing]);
console.log(question);
isEditing &&
setIsEditing([...isEditing, { qid: question._id, isEditing: true }]);
setSurvey({ ...survey, questions: questions });
// setSurvey({ ...survey, questions: questions });
setSurvey({ ...survey, questions: [...questions, question] });
setSuccess(true);
setError("");
} else {
......
......@@ -96,18 +96,24 @@ export const EditSurvey = () => {
async function addQuestion() {
try {
if (surveyId) {
const questions: BasicQuestionType[] = await questionApi.createQuestion(
// const questions: BasicQuestionType[] = await questionApi.createQuestion(
// surveyId
// );
// console.log(questions);
const question: BasicQuestionType = await questionApi.createQuestion(
surveyId
);
console.log(questions);
console.log(question);
const addedEditing = questions.map((question) => {
return { qid: question._id, isEditing: false };
});
console.log("added editing", addedEditing);
setIsEditing([...addedEditing]);
// const addedEditing = questions.map((question) => {
// return { qid: question._id, isEditing: false };
// });
// console.log("added editing", addedEditing);
isEditing &&
setIsEditing([...isEditing, { qid: question._id, isEditing: true }]);
setSurvey({ ...survey, questions: questions });
// setSurvey({ ...survey, questions: questions });
setSurvey({ ...survey, questions: [...questions, question] });
setSuccess(true);
setError("");
} else {
......
......@@ -24,7 +24,8 @@ export const createQuestion = asyncWrap(
surveyId
);
console.log(updatedSurvey);
return res.json(updatedSurvey?.questions);
// return res.json(updatedSurvey?.questions);
return res.json(newQuestion);
}
} catch (error: any) {
return res
......
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