fix: 컨텐츠 없을 때 에러 발생하는 문제 해결

This commit is contained in:
jhynsoo 2024-07-29 10:59:12 +09:00
parent 7321323b70
commit e952a57164
9 changed files with 10 additions and 12 deletions

View File

@ -13,7 +13,7 @@ export default function ArticlePreview({ to, title, contents = [] }) {
<RightIcon />
</Link>
<div className={styles.main}>
{contents.map((content) => {
{contents.map?.((content) => {
return (
<Link
to={`${to}/${content.id}`}

View File

@ -14,7 +14,7 @@ export default function ChatRoom() {
className={styles.messageList}
ref={chatListRef}
>
{messages.map((message) => (
{messages.map?.((message) => (
<li
key={message.id}
className={message.isMine ? styles.my : styles.your}

View File

@ -11,7 +11,6 @@
.title {
margin: 0;
padding: 16px;
z-index: 9;
}
.messageList {
@ -97,7 +96,6 @@
border-radius: 12px;
box-shadow: var(--shadow);
overflow: hidden;
z-index: 9;
& > input[type='text'] {
flex: 1;

View File

@ -14,7 +14,7 @@ export default function LearningLecturesPage() {
<section>
<h2 className={styles.title}>수강중인 강의</h2>
<div className={styles.grid}>
{onGoingClasses.map((lecture) => (
{onGoingClasses.map?.((lecture) => (
<Link
key={lecture.lecture_id}
to={`/lecture/${lecture.lecture_id}`}

View File

@ -13,7 +13,7 @@ export default function NoticeListPage() {
title="공지사항"
canCreate={false}
>
{notices?.map((notice) => (
{notices?.map?.((notice) => (
<ArticleLink
key={`${notice.id}`}
title={notice.title}

View File

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

View File

@ -13,12 +13,12 @@ export default function StudentHomePage() {
};
const { data } = useLectures();
const allClasses = data?.data;
const allClasses = data?.data ?? [];
return (
<MaxWidthLayout>
<ClassGrid title="수강중인 강의">
{onGoingClasses.map((lecture) => (
{onGoingClasses.map?.((lecture) => (
<ClassCard
key={lecture.lecture_id}
path={`/lecture/${lecture.lecture_id}`}
@ -28,7 +28,7 @@ export default function StudentHomePage() {
))}
</ClassGrid>
<ClassGrid title="전체 강의">
{allClasses?.map((lecture) => (
{allClasses.map?.((lecture) => (
<ClassCard
key={lecture.id}
path={`/lecture/${lecture.id}/info`}

View File

@ -14,7 +14,7 @@ export default function StudentListPage() {
return (
<ArticleBoard title="수강생 관리">
{students.map((student) => {
{students.map?.((student) => {
return (
<ArticleLink
key={`${student.name}${student.sub}`}

View File

@ -16,7 +16,7 @@ export default function TeacherNoticeListPage() {
title="공지사항"
canCreate={true}
>
{notices.map((notice) => {
{notices.map?.((notice) => {
if (notice.sub && notice.title) {
return (
<ArticleLink