"use client"; import { useEffect, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { getListArticle } from "@/service/article"; import { CommentIcon } from "../icons/sidebar-icon"; import { Button } from "../ui/button"; import { MessageCircle } from "lucide-react"; type Article = { id: number; title: string; description: string; categoryName: string; createdAt: string; createdByName: string; thumbnailUrl: string; categories: { title: string }[]; }; export default function Lifestyle() { const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); const [articles, setArticles] = useState([]); const [showData, setShowData] = useState("5"); const [visibleCount, setVisibleCount] = useState(4); const [search, setSearch] = useState(""); const [selectedCategories, setSelectedCategories] = useState(""); const [startDateValue, setStartDateValue] = useState({ startDate: null, endDate: null, }); useEffect(() => { fetchArticles(); }, [page, showData, startDateValue, selectedCategories]); async function fetchArticles() { const req = { limit: showData, page, search, categorySlug: Array.from(selectedCategories).join(","), sort: "desc", isPublish: true, sortBy: "created_at", }; try { const res = await getListArticle(req); setArticles(res?.data?.data || []); } catch (err) { console.error(err); } } return (

LIFESTYLE

{articles.slice(0, visibleCount).map((item) => ( {item.title}

{item.title}

{item.createdByName} {new Date(item.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })} 0 comments
))}
{visibleCount < articles.length && (
)}

Subscribe us to get the latest news!

Berita Utama

BUSINESS

{/* Grid artikel */}
{/* {articles.slice(0, visibleCount).map((item) => ( {item.title}

{item.title}

{item.createdByName} {new Date(item.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })} 0 comments
))} */}
{/* Load More button */} {/* {visibleCount < articles.length && (
)} */}
{/* Sidebar */} {/*

Subscribe us to get the latest news!

Berita Utama
*/}

SPORTS

{articles.slice(0, visibleCount).map((item) => ( {item.title}

{item.title}

{item.createdByName} - {new Date(item.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })}
))}
{visibleCount < articles.length && (
)}
Kolom Iklan

Join Us!

  • F Facebook
  • X Twitter
  • IG Instagram
  • Youtube
  • P Pinterest
  • D Dribbble

TECHNOLOGY

{articles.slice(0, visibleCount).map((item) => ( {item.title}

{item.title}

{item.createdByName} - {new Date(item.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })} 0 comments
))}
Berita Utama
{visibleCount < articles.length && (
)}

FASHION

{articles.slice(0, visibleCount).map((item) => ( {item.title}

{item.title}

{item.description}

{item.createdByName} - {new Date(item.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })} 0 comments
))}
Berita Utama
{visibleCount < articles.length && (
)}

Recent Post

{articles.map((post, idx) => ( {/* Thumbnail */} {post.title} {/* Konten */}

{post.categoryName}

{post.title}

{new Date(post.createdAt).toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })}
{/* Nomor urut */} {String(idx + 1).padStart(2, "0")} ))}
); }