"use client"; import React, { useState, useEffect } from "react"; import { backendUrl } from "@/utils/axios"; import axios from "axios"; import Image from "next/image"; import { motion } from "framer-motion"; const cleanHTML = (html) => { if (!html) return ""; return html.replace(/style="[^"]*color:[^;]*;?"/gi, ""); }; const SubcategoryHero = ({ params }) => { const [selectedCategory, setSubcategory] = useState(null); useEffect(() => { const fetchSubcategory = async () => { try { const response = await axios.get( `${backendUrl}/admins/product/subcategory/${params.subCategoryId}` ); console.log(response.data) const selectedSubcategory = response.data setSubcategory(selectedSubcategory); } catch (error) { console.error("Error fetching subcategory:", error); } }; fetchSubcategory(); }, [params.subCategoryId]); // Fallback values const fallbackImage = "/placeholder-image.jpg"; const fallbackDescription = "Explore our curated collection of spiritual items designed to enhance your journey of self-discovery and inner peace."; const fallbackCategoryName = "Spiritual Essentials"; return (
Category Background
{selectedCategory?.subcategory_name || fallbackCategoryName}
); }; export default SubcategoryHero;