diff --git a/components/landing-page/footer.tsx b/components/landing-page/footer.tsx index 3fd5f45..75ec946 100644 --- a/components/landing-page/footer.tsx +++ b/components/landing-page/footer.tsx @@ -1,105 +1,204 @@ "use client"; +import { useEffect, useState } from "react"; import Image from "next/image"; +import Link from "next/link"; +import { Calendar } from "lucide-react"; +import { getListArticle } from "@/service/article"; + +// Definisi type +type Article = { + id: number; + title: string; + description: string; + categoryName: string; + createdAt: string; + createdByName: string; + thumbnailUrl: string; + categories: { title: string }[]; + files: { file_url: string; file_alt: string }[]; +}; export default function Footer() { + const [articles, setArticles] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetchArticles(); + }, []); + + async function fetchArticles() { + try { + const req = { + limit: "2", // ambil 2 berita untuk recent news + 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 artikel:", error); + } finally { + setLoading(false); + } + } + return ( -