From 6c28fd3a94f406f5fcc17de041b67b967a36ddf9 Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Fri, 26 Sep 2025 14:21:15 +0800 Subject: [PATCH] update edit dan detail --- components/details/details-content.tsx | 47 +++++++++++++++++++++----- service/article.ts | 19 +++++++---- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/components/details/details-content.tsx b/components/details/details-content.tsx index dbb183b..1d61f9f 100644 --- a/components/details/details-content.tsx +++ b/components/details/details-content.tsx @@ -56,6 +56,7 @@ export default function DetailContent() { const [selectedMainImage, setSelectedMainImage] = useState( null ); + const [selectedIndex, setSelectedIndex] = useState(0); const [tabArticles, setTabArticles] = useState([]); @@ -193,6 +194,14 @@ export default function DetailContent() { close(); } + if (!articleDetail?.files || articleDetail.files.length === 0) { + return ( +
+

Gambar tidak tersedia

+
+ ); + } + return ( <>
@@ -253,19 +262,41 @@ export default function DetailContent() {
- {articleDetail?.files?.[0]?.fileUrl ? ( + {/* Gambar utama */} +
Berita - ) : ( -
-

Gambar tidak tersedia

-
- )} +
+ + {/* Thumbnail */} +
+ {articleDetail.files.map((file: any, index: number) => ( + + ))} +
+ + {/* Slug */}

{articleDetail?.slug}

diff --git a/service/article.ts b/service/article.ts index 8faddf4..d5da725 100644 --- a/service/article.ts +++ b/service/article.ts @@ -1,6 +1,11 @@ import { PaginationRequest } from "@/types/globals"; import { httpGet } from "./http-config/http-base-services"; -import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services"; +import { + httpDeleteInterceptor, + httpGetInterceptor, + httpPostInterceptor, + httpPutInterceptor, +} from "./http-config/http-interceptor-services"; export async function getListArticle(props: PaginationRequest) { const { @@ -42,11 +47,13 @@ export async function getArticlePagination(props: PaginationRequest) { isBanner, } = props; return await httpGetInterceptor( - `/articles?limit=${limit}&page=${page}&title=${search}&startDate=${startDate || ""}&endDate=${ - endDate || "" - }&categoryId=${category || ""}&sortBy=${sortBy || "created_at"}&sort=${ - sort || "asc" - }&category=${categorySlug || ""}&isBanner=${isBanner || ""}` + `/articles?limit=${limit}&page=${page}&title=${search}&startDate=${ + startDate || "" + }&endDate=${endDate || ""}&categoryId=${category || ""}&sortBy=${ + sortBy || "created_at" + }&sort=${sort || "asc"}&category=${categorySlug || ""}&isBanner=${ + isBanner || "" + }` ); }