feat: 퀴즈셋 상세페이지에서 tested에 따라 수정 버튼 표시 기능 추가

This commit is contained in:
정기영 2024-08-08 13:20:52 +09:00
parent 99e3cb5248
commit b6604426cd
3 changed files with 63 additions and 23 deletions

View File

@ -3,20 +3,39 @@ import { Link } from 'react-router-dom';
import styles from './QuizsetDetail.module.css'; import styles from './QuizsetDetail.module.css';
import { QuizDetailCard } from '../QuizForm'; import { QuizDetailCard } from '../QuizForm';
export default function QuizsetDetail({ topic, title, quizzes = [], onDelete, onEdit }) { export default function QuizsetDetail({ topic, title, quizzes = [], onDelete, onEdit, tested = false }) {
console.log('topic', topic, 'title', title, 'quizzes', quizzes); console.log('topic', topic, 'title', title, 'quizzes', quizzes);
return ( return (
<div className={styles.quizsetDetail}> <div className={styles.quizsetDetail}>
<header className={styles.header}> <header className={styles.header}>
<Link <div className={styles.headerInside}>
to={'..'} <Link
className={styles.goBack} to={'..'}
> className={styles.goBack}
<BackIcon /> >
<span>{topic}</span> <BackIcon />
</Link> <span>{topic}</span>
<div> </Link>
<h1 className={styles.title}>{title}</h1> <div>
<h1 className={styles.title}>{title}</h1>
</div>
</div>
<div className={styles.actionGroup}>
{!tested && (
<button
className={styles.edit}
onClick={onEdit}
>
수정
</button>
)}
<button
type="button"
className={styles.delete}
onClick={onDelete}
>
삭제
</button>
</div> </div>
</header> </header>
<div className={styles.grid}> <div className={styles.grid}>
@ -31,18 +50,7 @@ export default function QuizsetDetail({ topic, title, quizzes = [], onDelete, on
/> />
))} ))}
</div> </div>
<button {tested && <div className={styles.tested}>이미 진행된 퀴즈는 수정이 불가능합니다.</div>}
type="button"
onClick={onDelete}
>
퀴즈셋 삭제
</button>
<button
type="button"
onClick={onEdit}
>
퀴즈셋 수정
</button>
</div> </div>
); );
} }

View File

@ -11,12 +11,25 @@
} }
.header { .header {
display: flex;
justify-content: space-between;
align-items: end;
}
.headerInside {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: start; align-items: start;
gap: 8px; gap: 8px;
} }
.actionGroup {
display: flex;
align-items: end;
gap: 20px;
color: var(--text-color);
}
.goBack { .goBack {
display: flex; display: flex;
align-items: center; align-items: center;
@ -52,3 +65,20 @@
justify-content: start; justify-content: start;
margin-bottom: 40px; margin-bottom: 40px;
} }
.edit,
.delete {
padding: 0;
margin: 0;
border: none;
background-color: var(--background);
color: var(--text-color-tertiary);
font-size: 16px;
line-height: 1.4;
font-weight: 500;
cursor: pointer;
}
.delete {
color: var(--error-color);
}

View File

@ -9,7 +9,8 @@ export default function QuizsetDetailPage() {
const { quizsetDelete } = useQuizsetDelete(); const { quizsetDelete } = useQuizsetDelete();
const { data } = useTeacherQuizsetDetail(quizsetId); const { data } = useTeacherQuizsetDetail(quizsetId);
const quizset = data.data; const quizset = data.data;
console.log(quizset); const tested = quizset.tested;
console.log(tested);
const handleEdit = () => { const handleEdit = () => {
navigate('edit', { state: { initialValue: quizset } }); navigate('edit', { state: { initialValue: quizset } });
}; };
@ -25,6 +26,7 @@ export default function QuizsetDetailPage() {
quizzes={quizset.quizzes} quizzes={quizset.quizzes}
onDelete={handleDelete} onDelete={handleDelete}
onEdit={handleEdit} onEdit={handleEdit}
tested={tested}
/> />
); );
} }