"use client"; import { Button, Card, CardFooter, CircularProgress, Image, ScrollShadow, } from "@heroui/react"; import { ChevronLeftIcon, ChevronRightIcon, EyeIcon } from "../icons"; import { Swiper, SwiperSlide, useSwiper } from "swiper/react"; import "swiper/css"; import "swiper/css/navigation"; import { Autoplay, Pagination, Navigation, Controller } from "swiper/modules"; import Link from "next/link"; import GPRKominfo from "../ui/social-media/gpr-kominfo"; import { useEffect, useState } from "react"; import { getListArticle } from "@/service/article"; import { convertDateFormat, textEllipsis } from "@/utils/global"; import { useTranslations } from "next-intl"; import { data } from "autoprefixer"; import { Controller as FormController } from "react-hook-form"; import { Nabla } from "next/font/google"; export default function HeaderNews() { const [article, setArticle] = useState([]); const t = useTranslations("Landing"); const [selectedTab, setSelectedTab] = useState("media"); const [hotNews, setHotNews] = useState([]); // useEffect(() => { // }, []); useEffect(() => { getArticle(); getHotNews(); }, []); async function getArticle() { const req = { page: 1, search: "", limit: "10", sort: "desc", isPublish: true, }; const response = await getListArticle(req); setArticle(response?.data?.data); } async function getHotNews() { const req = { page: 1, search: "", limit: "10", sortBy: "view_count", sort: "desc", category: "586", isPublish: true, }; const response = await getListArticle(req); setHotNews(response?.data?.data); } return (
{article ? ( { swiper.navigation.nextEl?.classList.add( "bg-white/70", "!text-black", "rounded-full", "!w-[32px]", "!h-[32px]" ); swiper.navigation.prevEl?.classList.add( "bg-white/70", "!text-black", "rounded-full", "!w-[32px]", "!h-[32px]" ); }} > {article?.map((newsItem: any, index: number) => ( headernews

{textEllipsis(newsItem.title, 40)}

{convertDateFormat(newsItem.createdAt)} WIB

{newsItem.viewCount === null ? 0 : newsItem.viewCount}

))}
) : ( )}

{t("berita")}

{hotNews?.map((data: any, index: number) => (
{/* headernews */}
{textEllipsis(data.title, 40)} {textEllipsis(data.title, 66)}

{convertDateFormat(data.createdAt)} WIB

{data.viewCount === null ? 0 : data.viewCount}

))}
{article ? ( { swiper.navigation.nextEl?.classList.add( "bg-white/70", "!text-black", "rounded-full", "!w-[40px]", "!h-[40px]" ); swiper.navigation.prevEl?.classList.add( "bg-white/70", "!text-black", "rounded-full", "!w-[40px]", "!h-[40px]" ); }} > {article?.map((newsItem: any, index: number) => ( headernews

{newsItem.title}

{convertDateFormat(newsItem.createdAt)} WIB

{newsItem.viewCount === null ? 0 : newsItem.viewCount}

))}
) : ( )}
{/* */} {selectedTab === "media" ? (
{article?.map((list: any, index: number) => (

{list?.title}

{convertDateFormat(list?.createdAt)} WIB

{list?.viewCount === null ? 0 : list?.viewCount}

))}
) : (
IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - POLRI PRESISI UNTUK INDONESIA ILM DIVHUMAS POLRI - POLRI PRESISI MENGAWAL PROSES VAKSINASI UNTUK MENGATASI PANDEMI COVID 19 IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - INDONESIA MENOLAK RADIKALISME IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - BHABINKAMTIBMAS SAHABAT MASYARAKAT
)}
); }