From 7be9fc3722215175a1ca19a7907681291f2ebbe9 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 13 May 2025 20:21:05 +0200 Subject: [PATCH] more fixes --- src/components/OffsetOrder.tsx | 66 ++-------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) diff --git a/src/components/OffsetOrder.tsx b/src/components/OffsetOrder.tsx index e17cc88..5364cae 100644 --- a/src/components/OffsetOrder.tsx +++ b/src/components/OffsetOrder.tsx @@ -64,9 +64,6 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr fetchPortfolio(); }, []); - const [portfolios, setPortfolios] = useState([]); - const [selectedPortfolioId, setSelectedPortfolioId] = useState(null); - const fetchPortfolio = async () => { try { const allPortfolios = await getPortfolios(); @@ -76,21 +73,19 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr throw new Error('No portfolios available'); } - setPortfolios(allPortfolios); - - // Set default portfolio - prefer one with "puffin" in the name, otherwise first one + // Only get the puffin portfolio, no selection allowed const puffinPortfolio = allPortfolios.find(p => p.name.toLowerCase().includes('puffin') || p.name.toLowerCase().includes('maritime') ); if (puffinPortfolio) { + console.log('[OffsetOrder] Found Puffin portfolio with ID:', puffinPortfolio.id); setPortfolio(puffinPortfolio); - setSelectedPortfolioId(puffinPortfolio.id); } else { // Default to first portfolio if no puffin portfolio found + console.log('[OffsetOrder] No Puffin portfolio found, using first available portfolio with ID:', allPortfolios[0].id); setPortfolio(allPortfolios[0]); - setSelectedPortfolioId(allPortfolios[0].id); } } catch (err) { setError('Failed to fetch portfolio information. Please try again.'); @@ -99,15 +94,6 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr } }; - // Handle portfolio selection change - const handlePortfolioChange = (portfolioId: number) => { - const selected = portfolios.find(p => p.id === portfolioId); - if (selected) { - setPortfolio(selected); - setSelectedPortfolioId(portfolioId); - } - }; - const handleOffsetOrder = async () => { if (!portfolio) return; @@ -311,52 +297,6 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr ) : portfolio ? ( <> - {portfolios.length > 0 && ( -
-

- Select A Carbon Offset Portfolio -

- -
- {portfolios.map((p) => ( -
handlePortfolioChange(p.id)} - className={`cursor-pointer border rounded-lg p-4 transition-all ${ - selectedPortfolioId === p.id - ? 'border-blue-500 bg-blue-50 shadow-md' - : 'border-gray-200 hover:border-blue-300 hover:bg-blue-50' - }`} - > -
-

{p.name}

- {selectedPortfolioId === p.id && ( -
- -
- )} -
-

- {p.description} -

-
-
- {p.projects?.length || 0} project{p.projects?.length !== 1 ? 's' : ''} -
-
- {formatCurrency(p.pricePerTon, getCurrencyByCode(currency))}/ton -
-
-
- ))} -
- -

- Click on a portfolio to select which climate projects you'd like to support. -

-
- )} -

{portfolio.name}