From 210f4b06c739451031115e0c2b20a7477d4734e5 Mon Sep 17 00:00:00 2001 From: minwucho Date: Thu, 8 Aug 2024 17:51:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B0=95=EC=82=AC=EC=9D=98=20Qna=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Article/ArticleDetail/ArticleDetail.jsx | 14 +++++--- .../ArticleDetailAnswer.jsx | 36 ++++++++++--------- .../ArticleDetailAnswerInput.jsx | 11 ++++-- .../QuestionListPage/QuestionListPage.jsx | 1 - 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx b/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx index 0d6150e..af99fe7 100644 --- a/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx +++ b/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx @@ -55,7 +55,7 @@ export default function ArticleDetail({
- {(isMine || userType === 'teacher') && ( + {(isMine || (userType === 'teacher' && !isQna)) && ( <> ) : ( - + userType === 'teacher' && ( + + ) ))}
); diff --git a/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswer.jsx b/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswer.jsx index 24b481b..e28bb7d 100644 --- a/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswer.jsx +++ b/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswer.jsx @@ -3,7 +3,7 @@ import ReplyIcon from '/src/assets/icons/reply.svg?react'; import { useParams } from 'react-router-dom'; import { useAnswerDelete } from '../../../../hooks/api/useAnswerDelete'; -export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmit }) { +export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmit, isTeacher }) { const { questionId } = useParams(); const { answerDelete } = useAnswerDelete(); @@ -20,22 +20,24 @@ export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmi
선생님의 답변
-
- - -
+ {isTeacher && ( +
+ + +
+ )}

{answer}

diff --git a/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswerInput.jsx b/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswerInput.jsx index 284401a..57e4b3f 100644 --- a/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswerInput.jsx +++ b/frontend/src/components/Article/ArticleDetail/ArticleDetailAnswer/ArticleDetailAnswerInput.jsx @@ -1,16 +1,23 @@ import styles from './ArticleDetailAnswerInput.module.css'; import { useAnswerWrite } from '../../../../hooks/api/useAnswerWrite'; +import { useAnswerEdit } from '../../../../hooks/api/useAnswerEdit'; import { useParams } from 'react-router-dom'; import { useState } from 'react'; -export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer }) { +export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer, isEditing = false }) { const { answerWrite } = useAnswerWrite(); + const { answerEdit } = useAnswerEdit(); const { questionId } = useParams(); const [newAnswer, setNewAnswer] = useState(initialAnswer); const handleSubmit = async (e) => { e.preventDefault(); - await answerWrite(questionId, newAnswer); + console.log(isEditing); + if (isEditing) { + await answerEdit(questionId, newAnswer); + } else { + await answerWrite(questionId, newAnswer); + } onSubmit(newAnswer); }; diff --git a/frontend/src/pages/QuestionListPage/QuestionListPage.jsx b/frontend/src/pages/QuestionListPage/QuestionListPage.jsx index b81a1d8..c262638 100644 --- a/frontend/src/pages/QuestionListPage/QuestionListPage.jsx +++ b/frontend/src/pages/QuestionListPage/QuestionListPage.jsx @@ -9,7 +9,6 @@ export default function QuestionListPage() { const { data } = useQnas(lectureId); const questions = data?.data; const userType = useBoundStore((state) => state.userType); - return (