fix: 글 목록 0개일 때 표시 수정

This commit is contained in:
jhynsoo 2024-08-12 09:35:15 +09:00
parent 62fca020d9
commit f98ba270a4
7 changed files with 10 additions and 9 deletions

View File

@ -1,6 +1,7 @@
import EditIcon from '/src/assets/icons/edit.svg?react';
import { Link } from 'react-router-dom';
import styles from './ArticleBoard.module.css';
import { Children } from 'react';
export default function ArticleBoard({ title, canCreate, children }) {
return (
@ -19,7 +20,7 @@ export default function ArticleBoard({ title, canCreate, children }) {
)}
</div>
<div className={styles.article}>
{children ? children : <div className={styles.empty}>표시할 내용이 없습니다.</div>}
{Children.toArray(children).length ? children : <div className={styles.empty}>표시할 내용이 없습니다.</div>}
</div>
</div>
);

View File

@ -7,14 +7,14 @@ import IntersectionArea from '../../components/IntersectionArea/IntersectionObse
export default function NoticeListPage() {
const { lectureId } = useParams();
const { data, fetchNextPage, hasNextPage } = useFreeboards(lectureId);
const articles = data?.pages.flatMap((page) => page.data);
const articles = data.pages.flatMap((page) => page.data);
return (
<ArticleBoard
title="자유게시판"
canCreate={true}
>
{articles.length &&
{articles.length > 0 &&
articles.map?.((notice) => (
<ArticleLink
key={`${notice.id}`}

View File

@ -8,7 +8,7 @@ import IntersectionArea from '../../components/IntersectionArea/IntersectionObse
export default function NoticeListPage() {
const { lectureId } = useParams();
const { data, fetchNextPage, hasNextPage } = useNotices(lectureId);
const notices = data?.pages.flatMap((page) => page.data);
const notices = data.pages.flatMap((page) => page.data);
const userType = useBoundStore((state) => state.userType);
return (
@ -16,7 +16,7 @@ export default function NoticeListPage() {
title="공지사항"
canCreate={userType === 'teacher'}
>
{notices.length &&
{notices.length > 0 &&
notices.map?.((notice) => (
<ArticleLink
key={`${notice.id}`}

View File

@ -15,7 +15,7 @@ export default function QuestionListPage() {
title="Q&A"
canCreate={userType === 'student'}
>
{questions.length &&
{questions.length > 0 &&
questions.map?.((question) => (
<ArticleLink
key={`${question.title}${question.createtAt}`}

View File

@ -13,7 +13,7 @@ export default function QuizsetListPage() {
title="퀴즈 목록"
canCreate={true}
>
{quizsets.length &&
{quizsets.length > 0 &&
quizsets.map?.((quizset) => (
<ArticleLink
key={`${quizset.quizSetId}`}

View File

@ -14,7 +14,7 @@ export default function StudentListPage() {
return (
<ArticleBoard title="수강생 관리">
{students.length &&
{students.length > 0 &&
students.map?.((student) => {
return (
<ArticleLink

View File

@ -14,7 +14,7 @@ export default function TeacherReportsetDetailPage() {
title="퀴즈 조회"
canCreate={false}
>
{reports.length &&
{reports.length > 0 &&
reports.map?.((report) => {
return (
<ArticleLink