Merge branch 'fe/fixQna' into 'frontend'
[Front-end] fix: 강사의 Qna 관리부분 수정 See merge request s11-webmobile1-sub2/S11P12A701!117
This commit is contained in:
commit
546a226df8
@ -55,7 +55,7 @@ export default function ArticleDetail({
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.actionGroup}>
|
||||
{(isMine || userType === 'teacher') && (
|
||||
{(isMine || (userType === 'teacher' && !isQna)) && (
|
||||
<>
|
||||
<Link
|
||||
className={styles.edit}
|
||||
@ -84,12 +84,16 @@ export default function ArticleDetail({
|
||||
answer={submittedAnswer}
|
||||
onEditClick={handleEditClick}
|
||||
onDeleteSubmit={handleDeleteSubmit}
|
||||
isTeacher={userType === 'teacher'}
|
||||
/>
|
||||
) : (
|
||||
userType === 'teacher' && (
|
||||
<ArticleDetailAnswerInput
|
||||
onSubmit={handleAnswerSubmit}
|
||||
initialAnswer={submittedAnswer}
|
||||
isEditing={isEditing}
|
||||
/>
|
||||
)
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
@ -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,6 +20,7 @@ export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmi
|
||||
<div className={styles.author}>
|
||||
<ReplyIcon /> <span>선생님의 답변</span>
|
||||
</div>
|
||||
{isTeacher && (
|
||||
<div className={styles.actionGroup}>
|
||||
<button
|
||||
type="button"
|
||||
@ -36,6 +37,7 @@ export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmi
|
||||
<div>삭제</div>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className={styles.content}>{answer}</p>
|
||||
</section>
|
||||
|
@ -1,18 +1,24 @@
|
||||
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, isEditing = false }) {
|
||||
import SendIcon from '/src/assets/icons/send.svg?react';
|
||||
|
||||
export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer }) {
|
||||
const { answerWrite } = useAnswerWrite();
|
||||
const { answerEdit } = useAnswerEdit();
|
||||
const { questionId } = useParams();
|
||||
const [newAnswer, setNewAnswer] = useState(initialAnswer);
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
console.log(isEditing);
|
||||
if (isEditing) {
|
||||
await answerEdit(questionId, newAnswer);
|
||||
} else {
|
||||
await answerWrite(questionId, newAnswer);
|
||||
}
|
||||
onSubmit(newAnswer);
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,6 @@ export default function QuestionListPage() {
|
||||
const { data } = useQnas(lectureId);
|
||||
const questions = data?.data;
|
||||
const userType = useBoundStore((state) => state.userType);
|
||||
|
||||
return (
|
||||
<ArticleBoard
|
||||
title="Q&A"
|
||||
|
Loading…
Reference in New Issue
Block a user