'use client'; import Link from "next/link"; import { useState } from "react"; import { locations, locationsItem } from "@/utils/constant.utils"; export default function PortfolioFilter1() { const [activeCategory, setActiveCategory] = useState("all"); const filteredItems = activeCategory === "all" ? locationsItem : locationsItem.filter(item => Array.isArray(item.categories) && item.categories.includes(activeCategory) ); const firstRow = locations.slice(0, 3); const secondRow = locations.slice(3, 7); const getButtonStyle = (key) => { if (activeCategory === key) { return { cursor: "pointer", backgroundColor: "#bc0000", color: "#fff", border: "1px solid #bc0000", }; } else { return { cursor: "pointer", color: "black", border: "1px solid #102548", backgroundColor: "transparent", }; } }; return (
    {firstRow.map((cat) => (
  • setActiveCategory(cat.key)} style={getButtonStyle(cat.key)} > {cat.label}
  • ))}
    {secondRow.map((cat) => (
  • setActiveCategory(cat.key)} style={getButtonStyle(cat.key)} > {cat.label}
  • ))}
{filteredItems.length > 0 ? ( filteredItems.map((item, i) => (

{item.title || "Gallery Title"}

)) ) : (

No items found in this category.

)}
); }