import { Button, Card, CardBody, CardFooter, Image, Tab, Tabs, } from "@nextui-org/react"; import React, { useEffect, useState } from "react"; import { Swiper, SwiperSlide } from "swiper/react"; import "swiper/css"; import "swiper/css/navigation"; import "swiper/css/pagination"; import { Navigation, Pagination } from "swiper/modules"; import { topNewsMediahub } from "@/service/medol-news-update"; import Link from "next/link"; import { getImageInp, topNewsInp, topNewsTbn, } from "@/service/third-party-service"; import { convertDateFormatNoTime } from "@/utils/global"; import PolriTvWidget from "../ui/social-media/polri-tv"; import { useTranslations } from "next-intl"; export default function MedolUpdate() { const [selectedTab, setSelectedTab] = useState("mediahub"); const [mediahubUpdate, setMediahubUpdate] = useState([]); const [tbnUpdate, setTbnUpdate] = useState([]); const [inpUpdate, setInpUpdate] = useState([]); const t = useTranslations("Landing"); useEffect(() => { if (selectedTab === "mediahub" && mediahubUpdate?.length < 1) { getMedihubUpdate(); } if (selectedTab === "tbnews" && tbnUpdate?.length < 1) { getTbnUpdate(); } if (selectedTab === "inp" && inpUpdate?.length < 1) { getInpUpdate(); } }, [selectedTab]); async function getMedihubUpdate() { const res = await topNewsMediahub(); setMediahubUpdate(res?.data?.data?.content); } async function getTbnUpdate() { const res = await topNewsTbn(); setTbnUpdate(res?.data?.data); } async function getInpUpdate() { const res = await topNewsInp(); // setInpUpdate(res?.data); getDataImage(res?.data); } async function getDataImage(data: any) { let temp = data; for (let i = 0; i < data?.length; i++) { const res = await getImageInp(temp[i].id); const data = res?.data[0]?.guid?.rendered; temp[i].image = data; } setInpUpdate(temp); } return (
Top 5 News Update
{ 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]" ); }} > {mediahubUpdate?.map((newsItem: any) => ( tes

{convertDateFormatNoTime(newsItem?.createdAt)}

{newsItem?.title}
))}
{ 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]" ); }} > {tbnUpdate?.map((newsItem: any) => ( tes {convertDateFormatNoTime(newsItem?.date)} {newsItem?.title} ))}
{ 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]" ); }} > {inpUpdate?.map((newsItem: any) => ( tes {convertDateFormatNoTime(newsItem?.date)} {newsItem?.title?.rendered} ))}
); }