"use client"; import { BreadcrumbItem, Breadcrumbs, Button, Input, Pagination, } from "@nextui-org/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"; 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); useEffect(() => { getArticle(); }, [page]); async function getArticle() { // loading(); topRef.current?.scrollIntoView({ behavior: "smooth" }); const req = { page: page, search: search, limit: "9" }; 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")}`}

DIVISI HUMAS POLRI

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