"use-client"; 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 { useParams, usePathname, useRouter } from "next/navigation"; import { Icon } from "@iconify/react/dist/iconify.js"; import { formatDateToIndonesian } from "@/utils/globals"; import { getListContent } from "@/service/landing/landing"; import { Link } from "@/i18n/routing"; import { Reveal } from "./Reveal"; 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 = { page: 0, size: 5, 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" : props.type == "latest" ? "Terbaru" : "Serupa"}

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}{" "}

))}
) : (

empty

) ) : selectedTab == "audio" ? ( newContent?.length > 0 ? ( {newContent?.map((audio: any) => (
{formatDateToIndonesian(new Date(audio?.createdAt))} {audio?.timezone ? audio?.timezone : "WIB"} | {audio?.clickCount}{" "}
{audio?.title}
))}
) : (

empty

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

{image?.title}

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

))}
) : (

empty

) ) : newContent.length > 0 ? ( {newContent?.map((text: any) => (
{formatDateToIndonesian(new Date(text?.createdAt))} {text?.timezone ? text?.timezone : "WIB"}| {text?.clickCount}
{text?.title}
Download Dokumen
))}
) : (

empty

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