"use client"; import { useEffect, useState } from "react"; import Image from "next/image"; import { getListArticle } from "@/service/article"; import Link from "next/link"; type Article = { id: number; title: string; createdAt: string; createdByName: string; customCreatorName: string; thumbnailUrl: string; categories: { title: string }[]; }; export default function Story() { const [articles, setArticles] = useState([]); useEffect(() => { fetchArticles(); }, []); async function fetchArticles() { try { const req = { limit: "4", page: 1, search: "", categorySlug: "", sort: "desc", isPublish: true, sortBy: "created_at", }; const res = await getListArticle(req); setArticles(res?.data?.data || []); } catch (error) { console.error("Gagal memuat story:", error); } } if (articles.length < 4) return null; return (
{/* Title */}

Featured Story

{/* Grid Story */}
{articles.map((item) => (
{item.title}
{item.categories[0]?.title || "Uncategorized"}

{item.title}

))}
Kolom PPS
); }