"use client"; import { BreadcrumbItem, Breadcrumbs, Button, Input, Pagination, } from "@heroui/react"; import { CalendarIcon, Calender, ChevronRightIcon, ClockIcon, EyeFilledIcon, SearchIcon, UserIcon, } from "../../icons"; import Link from "next/link"; import { useEffect, useRef, useState } from "react"; import { getListArticle } from "@/service/article"; import { formatMonthString, htmlToString, textEllipsis } from "@/utils/global"; import Image from "next/image"; import { useParams } from "next/navigation"; export default function ListNews() { const [article, setArticle] = useState([]); const [search, setSearch] = useState(""); const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); const topRef = useRef(null); const params = useParams(); const category = params?.name; useEffect(() => { getArticle(); }, [page, category]); async function getArticle() { // loading(); topRef.current?.scrollIntoView({ behavior: "smooth" }); const req = { page: page, search: search, limit: "9", category: String(category), }; const response = await getListArticle(req); setArticle(response?.data?.data); setTotalPage(response?.data?.meta?.totalPage); // close(); } return (
Beranda

Berita

} type="search" />
{article?.map((news: any) => (
thumbnail
{news?.title}

{formatMonthString(news?.updatedAt)}

{`${new Date(news?.updatedAt) .getHours() .toString() .padStart(2, "0")}:${new Date(news?.updatedAt) .getMinutes() .toString() .padStart(2, "0")}`}

{news?.createdByName}

{textEllipsis(htmlToString(news?.description), 165)}
))}
); }