import { getPublicCategoryDataNew } from "@/service/landing/landing"; import React, { useEffect, useState } from "react"; import { Reveal } from "./Reveal"; import { useTranslations } from "next-intl"; import { usePathname } from "next/navigation"; import { useParams } from "next/navigation"; import { Link, useRouter } from "@/i18n/routing"; import { Button } from "../ui/button"; import ImageBlurry from "../ui/image-blurry"; const ContentCategory = (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 getPublicCategoryDataNew( 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" })} )}

{(seeAllValue ? categories : categories?.slice(0, 4))?.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}

) )}
{/* Tombol See More / See Less */} {categories?.length > 4 && (
)} {/*
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 ContentCategory;