puffin-app/components/CalculatorClient.tsx
Matt 848a8be995
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m23s
Add standards legend to offset order page with proper positioning
- Move StandardsLegend from calculator input page to OffsetOrder page
- Position after project cards and before offset amount slider
- Update Wren certification link to https://www.wren.co/certification
- Add vertical spacing (mb-8) below the dropdown for better layout
2025-11-04 16:09:18 +01:00

80 lines
2.4 KiB
TypeScript

'use client';
import { useState } from 'react';
import { TripCalculator } from '../src/components/TripCalculator';
import { QRCalculatorLoader } from '../src/components/QRCalculatorLoader';
import { OffsetOrder } from '../src/components/OffsetOrder';
import { useHasQRData } from '../src/hooks/useQRDecoder';
import type { VesselData } from '../src/types';
// Sample vessel data (same as in old App.tsx)
const sampleVessel: VesselData = {
imo: "1234567",
vesselName: "Sample Yacht",
type: "Yacht",
length: 50,
width: 9,
estimatedEnginePower: 2250
};
export function CalculatorClient() {
const hasQRData = useHasQRData(); // Check if URL contains QR code data
const [showOffsetOrder, setShowOffsetOrder] = useState(false);
const [offsetTons, setOffsetTons] = useState(0);
const [monetaryAmount, setMonetaryAmount] = useState<number | undefined>();
const handleOffsetClick = (tons: number, monetaryAmount?: number) => {
setOffsetTons(tons);
setMonetaryAmount(monetaryAmount);
setShowOffsetOrder(true);
window.scrollTo({ top: 0, behavior: 'smooth' });
};
const handleBackFromOffset = () => {
setShowOffsetOrder(false);
setOffsetTons(0);
setMonetaryAmount(undefined);
window.scrollTo({ top: 0, behavior: 'smooth' });
};
if (showOffsetOrder) {
return (
<div className="flex justify-center px-4 sm:px-0">
<OffsetOrder
tons={offsetTons}
monetaryAmount={monetaryAmount}
onBack={handleBackFromOffset}
calculatorType="trip"
/>
</div>
);
}
return (
<div className="flex flex-col items-center">
<div className="text-center mb-12 max-w-4xl">
<h1 className="text-3xl sm:text-4xl font-bold text-gray-900 mb-4">
Calculate & Offset Your Yacht&apos;s Carbon Footprint
</h1>
<p className="text-base sm:text-lg text-gray-600">
Use the calculator below to estimate your carbon footprint and explore offsetting options through our verified projects.
</p>
</div>
<div className="flex flex-col items-center w-full max-w-4xl space-y-8">
{hasQRData ? (
<QRCalculatorLoader
vesselData={sampleVessel}
onOffsetClick={handleOffsetClick}
/>
) : (
<TripCalculator
vesselData={sampleVessel}
onOffsetClick={handleOffsetClick}
/>
)}
</div>
</div>
);
}