diff --git a/src/components/OffsetOrder.tsx b/src/components/OffsetOrder.tsx index b53fe37..8c64fce 100644 --- a/src/components/OffsetOrder.tsx +++ b/src/components/OffsetOrder.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { Check, AlertCircle, ArrowLeft, Loader2, Globe2, TreePine, Waves, Factory, Wind, X } from 'lucide-react'; -import { motion, AnimatePresence } from 'framer-motion'; +import { motion } from 'framer-motion'; import { createOffsetOrder, getPortfolios } from '../api/wrenClient'; import type { CurrencyCode, OffsetOrder as OffsetOrderType, Portfolio, OffsetProject } from '../types'; import { currencies, formatCurrency, getCurrencyByCode } from '../utils/currencies'; @@ -128,26 +128,18 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr // Calculate offset cost using the portfolio price const offsetCost = monetaryAmount || (portfolio ? tons * (portfolio.pricePerTon || 18) : 0); - // Simplified handler for project selection with maximum debugging - const handleProjectClick = (project: OffsetProject) => { - console.log('=== PROJECT CLICK HANDLER FIRED ==='); - console.log('Project name:', project.name); - console.log('Project ID:', project.id); - console.log('Current selectedProject state:', selectedProject?.name || 'null'); - - // Force the state update + // Completely simplified project selection handler + const handleProjectClick = (project: OffsetProject, e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + console.log('Opening project details for:', project.name); setSelectedProject(project); - - console.log('State updated to:', project.name); - console.log('=== END PROJECT CLICK HANDLER ==='); }; - // Handler for closing the lightbox - const handleCloseLightbox = (e: React.MouseEvent | React.TouchEvent) => { - if (e) e.preventDefault(); - console.log('=== CLOSING LIGHTBOX ==='); + // Simple lightbox close handler + const handleCloseLightbox = () => { + console.log('Closing lightbox'); setSelectedProject(null); - console.log('selectedProject set to null'); }; return ( @@ -351,16 +343,13 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr animate={{ opacity: 1 }} transition={{ duration: 0.5, delay: 0.3 }} > - {portfolio.projects.map((project, index) => ( + {portfolio.projects.map((project) => (