diff --git a/src/components/OffsetOrder.tsx b/src/components/OffsetOrder.tsx index 8c64fce..63f4de0 100644 --- a/src/components/OffsetOrder.tsx +++ b/src/components/OffsetOrder.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useCallback } from 'react'; import { Check, AlertCircle, ArrowLeft, Loader2, Globe2, TreePine, Waves, Factory, Wind, X } from 'lucide-react'; import { motion } from 'framer-motion'; import { createOffsetOrder, getPortfolios } from '../api/wrenClient'; @@ -128,13 +128,21 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr // Calculate offset cost using the portfolio price const offsetCost = monetaryAmount || (portfolio ? tons * (portfolio.pricePerTon || 18) : 0); - // Completely simplified project selection handler - const handleProjectClick = (project: OffsetProject, e: React.MouseEvent) => { - e.preventDefault(); - e.stopPropagation(); + // Robust project click handler with multiple fallbacks + const handleProjectClick = useCallback((project: OffsetProject, e?: React.MouseEvent) => { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } console.log('Opening project details for:', project.name); setSelectedProject(project); - }; + }, []); + + // Additional handler for direct button clicks + const handleProjectButtonClick = useCallback((project: OffsetProject) => { + console.log('Button click - Opening project details for:', project.name); + setSelectedProject(project); + }, []); // Simple lightbox close handler const handleCloseLightbox = () => { @@ -343,56 +351,96 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr animate={{ opacity: 1 }} transition={{ duration: 0.5, delay: 0.3 }} > - {portfolio.projects.map((project) => ( -
+ + {/* Description */} +
{project.shortDescription || project.description}
-