import { getCategoryData, getPublicCategoryData, } from "@/service/landing/landing"; import React, { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; import { usePathname } from "next/navigation"; import { useParams } from "next/navigation"; import Image from "next/image"; import { useRouter } from "@/i18n/routing"; import { Reveal } from "../Reveal"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel"; const ContentCategoryKaltara = (props: { group?: string; type: string }) => { const [categories, setCategories] = useState(); const t = useTranslations("LandingPage"); const params = useParams(); const locale = params?.locale; const [selectedTab, setSelectedTab] = useState("image"); const poldaName = params?.polda_name; const satkerName = params?.satker_name; const router = useRouter(); let prefixPath = poldaName ? `/polda/${poldaName}` : satkerName ? `/satker/${satkerName}` : "/"; useEffect(() => { initFetch(); }, []); const initFetch = async () => { const response = await getPublicCategoryData( props.group == "mabes" ? "" : props.group == "polda" && poldaName && String(poldaName)?.length > 1 ? poldaName : props.group == "satker" && satkerName && String(satkerName)?.length > 1 ? "satker-" + satkerName : "", "", locale == "en" ? true : false ); console.log("category", response); setCategories(response?.data?.data?.content); }; const [searchTerm, setSearchTerm] = useState(""); const [seeAllValue, setSeeAllValue] = useState(false); const pathname = usePathname(); const shimmer = (w: number, h: number) => ` `; const toBase64 = (str: string) => typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str); return (

{pathname?.split("/")[1] == "in" ? ( <> {t("category", { defaultValue: "Category" })}  {t("content", { defaultValue: "Content" })} ) : ( <> {t("content", { defaultValue: "Content" })}  {t("category", { defaultValue: "Category" })} )}

{categories?.map((category: any) => (
router.push(prefixPath + `all/filter?category=${category?.id}`)} className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block"> {/* Gambar */} category {/* Overlay gelap */}
{/* Judul */}

{category?.name}

))}
{/*
*/}
router.push( prefixPath + `/${selectedTab}/filter?sortBy=${props.type}` ) } className="cursor-pointer border text-[#bb3523] rounded-lg text-sm lg:text-md px-4 py-1 border-[#bb3523]" > {t("seeAll", { defaultValue: "See All" })}
); }; export default ContentCategoryKaltara;