"use client"; import Link from "next/link"; import { Badge } from "@/components/ui/badge"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import type { PublicArticle } from "@/lib/articles-public"; import { NEWS_SERVICES_TAB_ORDER, NEWS_TAB_LABEL, type NewsServicesTab, } from "@/constants/news-services"; import { formatDate } from "@/utils/global"; import ArticleThumbnail from "@/components/landing-page/article-thumbnail"; const BADGE_COLORS = [ "bg-red-600", "bg-yellow-500", "bg-yellow-600", "bg-[#0f3b63]", ]; function firstTag(tags: string | undefined): string { if (!tags?.trim()) return ""; const t = tags .split(",") .map((s) => s.trim()) .filter(Boolean)[0]; return t ?? ""; } function articleHref(a: PublicArticle) { return `/news/detail/${a.id}-${a.slug}`; } type Props = { id?: string; title: string; articlesByTab: Record; showViews?: boolean; exploreHref?: string; exploreLabel?: string; }; export default function NewsServicesArticleSection({ id, title, articlesByTab, showViews, exploreHref = "#konten-terpopuler", exploreLabel = "Lihat konten terpopuler", }: Props) { const defaultTab = NEWS_SERVICES_TAB_ORDER[0]; return (

{title}

{NEWS_SERVICES_TAB_ORDER.map((tab) => ( {NEWS_TAB_LABEL[tab]} ))}
{exploreLabel}
{NEWS_SERVICES_TAB_ORDER.map((tab) => ( ))}
); } function CardGrid({ articles, showViews, }: { articles: PublicArticle[]; showViews?: boolean; }) { if (articles.length === 0) { return (

Belum ada konten yang dipublikasikan untuk tab ini.

); } return (
{articles.map((item) => { const badgeClass = BADGE_COLORS[item.id % BADGE_COLORS.length]; const category = item.categoryName?.trim() || "Berita"; const tag = firstTag(item.tags); const dateSrc = item.publishedAt || item.createdAt; return (
{category} {tag ? ( {tag} ) : null}

{formatDate(dateSrc)} {showViews && item.viewCount != null ? ( ยท {item.viewCount} tayangan ) : null}

{item.title}

); })}
); }