feat: 강의 페이지 작성된 글 없을 때 레이아웃 추가

This commit is contained in:
jhynsoo 2024-08-07 10:10:12 +09:00
parent 6006eec42d
commit 89a3ea4568
6 changed files with 27 additions and 48 deletions

View File

@ -3,6 +3,8 @@ import styles from './ArticlePreview.module.css';
import RightIcon from '/src/assets/icons/right.svg?react';
export default function ArticlePreview({ to, title, contents = [] }) {
const hasContents = contents.length > 0;
return (
<div className={styles.wrapper}>
<Link
@ -13,17 +15,21 @@ export default function ArticlePreview({ to, title, contents = [] }) {
<RightIcon />
</Link>
<div className={styles.main}>
{contents.map?.((content) => {
return (
<Link
to={`${to}/${content.id}`}
key={content.id}
className={styles.content}
>
{content.title}
</Link>
);
})}
{hasContents ? (
contents.map?.((content) => {
return (
<Link
to={`${to}/${content.id}`}
key={content.id}
className={styles.content}
>
{content.title}
</Link>
);
})
) : (
<div className={styles.empty}>아직 작성된 글이 없습니다.</div>
)}
</div>
</div>
);

View File

@ -35,3 +35,13 @@
line-height: 1.4;
font-weight: 400;
}
.empty {
display: flex;
justify-content: center;
align-items: center;
padding: 20px 0;
color: var(--text-color-tertiary);
font-size: 16px;
line-height: 1.2;
}

View File

@ -24,7 +24,6 @@ export default function LearningLectureDetailPage() {
title="Q&A"
contents={questions}
/>
<ArticlePreview title="커리큘럼" />
</section>
);
}

View File

@ -1,30 +0,0 @@
import ArticlePreview from '../../components/Article/ArticlePreview/ArticlePreview';
import styles from './TeacherLectureDetailPage.module.css';
import { useNotices } from '../../hooks/api/useNotices';
import { useParams } from 'react-router-dom';
import { useQnas } from '../../hooks/api/useQnas';
export default function TeacherLectureDetailPage() {
const { lectureId } = useParams();
const { data: noticesData } = useNotices(lectureId);
const notices = noticesData?.data;
const { data: qnasData } = useQnas(lectureId);
const questions = qnasData?.data;
return (
<main className={styles.previews}>
{/* FIXME: 밑에 ArticlePreview 바꿔야함. 공지사항 Q&A 커리큘럼 으로 나눠서 작성할 수 있게 바꾸고 링크 상위 3개만 받고 링크 줄 수 있게 할지 말지. 이거 바꾸면 LearningLectureDetailPage도 똑같이 바꾸면 될듯*/}
<ArticlePreview
to="notice"
title="공지사항"
contents={notices}
/>
<ArticlePreview
to="qna"
title="Q&A"
contents={questions}
/>
<ArticlePreview title="커리큘럼" />
</main>
);
}

View File

@ -1,5 +0,0 @@
.previews {
display: flex;
flex-direction: column;
gap: 40px;
}

View File

@ -1 +0,0 @@
export { default } from './TeacherLectureDetailPage';