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>
|
</div>
|
||||||
<div className={styles.actionGroup}>
|
<div className={styles.actionGroup}>
|
||||||
{(isMine || userType === 'teacher') && (
|
{(isMine || (userType === 'teacher' && !isQna)) && (
|
||||||
<>
|
<>
|
||||||
<Link
|
<Link
|
||||||
className={styles.edit}
|
className={styles.edit}
|
||||||
@ -84,12 +84,16 @@ export default function ArticleDetail({
|
|||||||
answer={submittedAnswer}
|
answer={submittedAnswer}
|
||||||
onEditClick={handleEditClick}
|
onEditClick={handleEditClick}
|
||||||
onDeleteSubmit={handleDeleteSubmit}
|
onDeleteSubmit={handleDeleteSubmit}
|
||||||
|
isTeacher={userType === 'teacher'}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ArticleDetailAnswerInput
|
userType === 'teacher' && (
|
||||||
onSubmit={handleAnswerSubmit}
|
<ArticleDetailAnswerInput
|
||||||
initialAnswer={submittedAnswer}
|
onSubmit={handleAnswerSubmit}
|
||||||
/>
|
initialAnswer={submittedAnswer}
|
||||||
|
isEditing={isEditing}
|
||||||
|
/>
|
||||||
|
)
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,7 @@ import ReplyIcon from '/src/assets/icons/reply.svg?react';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useAnswerDelete } from '../../../../hooks/api/useAnswerDelete';
|
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 { questionId } = useParams();
|
||||||
const { answerDelete } = useAnswerDelete();
|
const { answerDelete } = useAnswerDelete();
|
||||||
|
|
||||||
@ -20,22 +20,24 @@ export default function ArticleDetailAnswer({ answer, onEditClick, onDeleteSubmi
|
|||||||
<div className={styles.author}>
|
<div className={styles.author}>
|
||||||
<ReplyIcon /> <span>선생님의 답변</span>
|
<ReplyIcon /> <span>선생님의 답변</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.actionGroup}>
|
{isTeacher && (
|
||||||
<button
|
<div className={styles.actionGroup}>
|
||||||
type="button"
|
<button
|
||||||
className={styles.edit}
|
type="button"
|
||||||
onClick={onEditClick}
|
className={styles.edit}
|
||||||
>
|
onClick={onEditClick}
|
||||||
수정
|
>
|
||||||
</button>
|
수정
|
||||||
<button
|
</button>
|
||||||
type="button"
|
<button
|
||||||
className={styles.delete}
|
type="button"
|
||||||
onClick={handleDeleteSubmit}
|
className={styles.delete}
|
||||||
>
|
onClick={handleDeleteSubmit}
|
||||||
<div>삭제</div>
|
>
|
||||||
</button>
|
<div>삭제</div>
|
||||||
</div>
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className={styles.content}>{answer}</p>
|
<p className={styles.content}>{answer}</p>
|
||||||
</section>
|
</section>
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
import styles from './ArticleDetailAnswerInput.module.css';
|
import styles from './ArticleDetailAnswerInput.module.css';
|
||||||
import { useAnswerWrite } from '../../../../hooks/api/useAnswerWrite';
|
import { useAnswerWrite } from '../../../../hooks/api/useAnswerWrite';
|
||||||
|
import { useAnswerEdit } from '../../../../hooks/api/useAnswerEdit';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer, isEditing = false }) {
|
||||||
import SendIcon from '/src/assets/icons/send.svg?react';
|
import SendIcon from '/src/assets/icons/send.svg?react';
|
||||||
|
|
||||||
export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer }) {
|
|
||||||
const { answerWrite } = useAnswerWrite();
|
const { answerWrite } = useAnswerWrite();
|
||||||
|
const { answerEdit } = useAnswerEdit();
|
||||||
const { questionId } = useParams();
|
const { questionId } = useParams();
|
||||||
const [newAnswer, setNewAnswer] = useState(initialAnswer);
|
const [newAnswer, setNewAnswer] = useState(initialAnswer);
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
await answerWrite(questionId, newAnswer);
|
console.log(isEditing);
|
||||||
|
if (isEditing) {
|
||||||
|
await answerEdit(questionId, newAnswer);
|
||||||
|
} else {
|
||||||
|
await answerWrite(questionId, newAnswer);
|
||||||
|
}
|
||||||
onSubmit(newAnswer);
|
onSubmit(newAnswer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ export default function QuestionListPage() {
|
|||||||
const { data } = useQnas(lectureId);
|
const { data } = useQnas(lectureId);
|
||||||
const questions = data?.data;
|
const questions = data?.data;
|
||||||
const userType = useBoundStore((state) => state.userType);
|
const userType = useBoundStore((state) => state.userType);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ArticleBoard
|
<ArticleBoard
|
||||||
title="Q&A"
|
title="Q&A"
|
||||||
|
Loading…
Reference in New Issue
Block a user