import React, { useEffect, useState } from "react"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel"; import Link from "next/link"; import { useParams, usePathname, useRouter } from "next/navigation"; import { Icon } from "@iconify/react/dist/iconify.js"; import { formatDateToIndonesian, textEllipsis } from "@/utils/globals"; import { generateLocalizedPath } from "@/utils/globals"; import { getListContent } from "@/service/landing/landing"; const NewContent = (props: { type: string }) => { const [newContent, setNewContent] = useState(); const [selectedTab, setSelectedTab] = useState("video"); const router = useRouter(); const pathname = usePathname(); const params = useParams(); const locale = params?.locale; useEffect(() => { initFetch(); }, [selectedTab]); const initFetch = async () => { const request = { sortBy: props.type == "popular" ? "clickCount" : "createdAt", contentTypeId: selectedTab == "image" ? "1" : selectedTab == "video" ? "2" : selectedTab == "text" ? "3" : selectedTab == "audio" ? "4" : "" }; const response = await getListContent(request); console.log("category", response); setNewContent(response?.data?.data?.content); }; return (

Konten  {props.type == "popular" ? "Populer" : "Terbaru"}

Audio Visual Audio Foto Teks
{selectedTab == "video" ? ( newContent?.length > 0 ? ( {newContent?.map((video: any) => (

{video?.title}

{formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"} | {video.clickCount}{" "} {" "}

))}
) : (

No Data

) ) : selectedTab == "audio" ? ( newContent?.length > 0 ? ( {newContent?.map((audio: any) => ( ))} ) : (

No Data

) ) : selectedTab == "image" ? ( newContent?.length > 0 ? ( {newContent?.map((image: any) => (

{image?.title}

{formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}| {image?.clickCount}{" "} {" "}

))}
) : (

No Data

) ) : newContent.length > 0 ? ( {newContent?.map((text: any) => ( ))} ) : (

No Data

)}
LIHAT SEMUA
); }; export default NewContent;