"use client"; import { useState } from "react"; import { projectsData } from "@/data/projects"; import React from "react"; import Image from "next/image"; import AnimatedText from "@/components/common/AnimatedText"; import Link from "next/link"; import Lightbox from "yet-another-react-lightbox"; import "yet-another-react-lightbox/styles.css"; const tabOptions = [ { key: "desiccated", label: "Coconut Milk Extraction" }, { key: "virgin", label: "Coconut Dryer Projects" }, { key: "pare", label: "Coconut Pulverizing & Grinding" }, ]; export default function ProjectsHomePreview() { const [activeTab, setActiveTab] = useState("desiccated"); const [lightboxOpen, setLightboxOpen] = useState(false); const [lightboxImages, setLightboxImages] = useState([]); const [currentImageIndex, setCurrentImageIndex] = useState(0); // Filter and limit projects based on tab const filteredProjects = projectsData .filter( (project) => project.category && project.category.toLowerCase().includes(activeTab) ) .slice(0, 6); // Limit to 6 per tab // Get all image URLs from filtered projects const imageList = filteredProjects.map((project) => project.images[0]); // Handle lightbox opening const handleImageClick = (imageSrc) => { const index = imageList.findIndex((img) => img === imageSrc); const slides = imageList.map((img) => ({ src: img })); setLightboxImages(slides); setCurrentImageIndex(index >= 0 ? index : 0); setLightboxOpen(true); }; return (
{/* Section Title */}
Our Global Footprint


{/* Tabs */}
{tabOptions.map((tab) => ( ))}
{/* Project Cards */}
{filteredProjects.map((project) => (
handleImageClick(project.images[0])} > {project.title}
))}
{/* Lightbox */} {lightboxOpen && ( setLightboxOpen(false)} slides={lightboxImages} index={currentImageIndex} /> )} {/* View More Button */}
View More Projects
); }