diff --git a/components/details/details-content.tsx b/components/details/details-content.tsx index 01efbe9..b6a7d75 100644 --- a/components/details/details-content.tsx +++ b/components/details/details-content.tsx @@ -294,7 +294,7 @@ export default function DetailContent() { async function initStateData() { loading(); const res = await getArticleById(id); - const data = res.data?.data; + const data = res?.data?.data; setThumbnail(data?.thumbnailUrl); setDiseId(data?.aiArticleId); @@ -303,13 +303,13 @@ export default function DetailContent() { close(); } - if (!articleDetail?.files || articleDetail.files.length === 0) { - return ( -
-

Gambar tidak tersedia

-
- ); - } + // if (!articleDetail?.files || articleDetail?.files?.length === 0) { + // return ( + //
+ //

Gambar tidak tersedia

+ //
+ // ); + // } return ( <> @@ -372,38 +372,50 @@ export default function DetailContent() {
{/* Gambar utama */} -
- {articleDetail.files[selectedIndex].fileAlt -
- - {/* Thumbnail */} -
- {articleDetail.files.map((file: any, index: number) => ( - - ))} -
+
+ + {/* Thumbnail */} +
+ {articleDetail.files.map((file: any, index: number) => ( + + ))} +
+ + ) : ( + // Jika file kosong/null tapi tetap render data lainnya +
+

Gambar tidak tersedia

+
+ )} {/* Slug */}

@@ -575,20 +587,20 @@ export default function DetailContent() {

Komentar

- {commentList.length === 0 ? ( + {commentList?.length === 0 ? (

Belum ada komentar.

) : ( - commentList.map((comment: any) => ( + commentList?.map((comment: any) => (

- {comment.message} + {comment?.message}

- {comment.commentFromName || "Anonim"} •{" "} - {new Date(comment.createdAt).toLocaleString("id-ID", { + {comment?.commentFromName || "Anonim"} •{" "} + {new Date(comment?.createdAt).toLocaleString("id-ID", { dateStyle: "short", timeStyle: "short", })}