2025-10-31 22:23:45 +01:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
2025-11-02 19:13:15 +01:00
|
|
|
|
import { useEffect, useState } from 'react';
|
2025-10-31 22:23:45 +01:00
|
|
|
|
import { useRouter } from 'next/navigation';
|
2025-11-02 19:13:15 +01:00
|
|
|
|
import { motion } from 'framer-motion';
|
|
|
|
|
|
import { Leaf } from 'lucide-react';
|
|
|
|
|
|
import { getOrderDetails } from '../../../src/api/checkoutClient';
|
|
|
|
|
|
import { OrderDetailsResponse } from '../../../src/types';
|
|
|
|
|
|
import { CarbonImpactComparison } from '../../../src/components/CarbonImpactComparison';
|
|
|
|
|
|
import { RechartsPortfolioPieChart } from '../../../src/components/RechartsPortfolioPieChart';
|
|
|
|
|
|
import { useCalculatorState } from '../../../src/hooks/useCalculatorState';
|
|
|
|
|
|
|
|
|
|
|
|
// Map backend status to user-friendly labels
|
|
|
|
|
|
const getStatusDisplay = (status: string): { label: string; className: string } => {
|
|
|
|
|
|
switch (status) {
|
|
|
|
|
|
case 'paid':
|
|
|
|
|
|
case 'fulfilled':
|
|
|
|
|
|
return { label: 'Confirmed', className: 'bg-green-100 text-green-700' };
|
|
|
|
|
|
case 'pending':
|
|
|
|
|
|
return { label: 'Processing', className: 'bg-yellow-100 text-yellow-700' };
|
|
|
|
|
|
default:
|
|
|
|
|
|
return { label: status.toUpperCase(), className: 'bg-slate-100 text-slate-700' };
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Format currency with commas
|
|
|
|
|
|
const formatCurrency = (amount: number): string => {
|
|
|
|
|
|
return amount.toLocaleString('en-US', {
|
|
|
|
|
|
minimumFractionDigits: 2,
|
|
|
|
|
|
maximumFractionDigits: 2
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2025-10-31 22:23:45 +01:00
|
|
|
|
|
|
|
|
|
|
export default function CheckoutSuccessPage() {
|
|
|
|
|
|
const router = useRouter();
|
2025-11-02 19:13:15 +01:00
|
|
|
|
const [orderDetails, setOrderDetails] = useState<OrderDetailsResponse | null>(null);
|
|
|
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
|
|
const { clearState } = useCalculatorState();
|
|
|
|
|
|
|
|
|
|
|
|
// Clear calculator state on successful payment (per user preference)
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (orderDetails && (orderDetails.order.status === 'paid' || orderDetails.order.status === 'fulfilled')) {
|
|
|
|
|
|
clearState();
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [orderDetails, clearState]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchOrderDetails = async () => {
|
|
|
|
|
|
// Get session ID from URL
|
|
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
|
|
const sessionId = params.get('session_id');
|
|
|
|
|
|
|
|
|
|
|
|
if (!sessionId) {
|
|
|
|
|
|
setError('No session ID found in URL');
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const details = await getOrderDetails(sessionId);
|
|
|
|
|
|
setOrderDetails(details);
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
setError('Failed to load order details');
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
fetchOrderDetails();
|
|
|
|
|
|
}, []);
|
2025-10-31 22:23:45 +01:00
|
|
|
|
|
2025-11-02 19:13:15 +01:00
|
|
|
|
if (loading) {
|
|
|
|
|
|
return (
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-cyan-50 flex items-center justify-center p-6">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, scale: 0.9 }}
|
|
|
|
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
|
|
|
|
className="text-center"
|
|
|
|
|
|
>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500 mx-auto"></div>
|
|
|
|
|
|
<p className="mt-4 text-slate-600 font-medium">Loading your order details...</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2025-10-31 22:23:45 +01:00
|
|
|
|
|
2025-11-02 19:13:15 +01:00
|
|
|
|
if (error || !orderDetails) {
|
|
|
|
|
|
return (
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-cyan-50 flex items-center justify-center p-6">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="max-w-md w-full bg-white rounded-2xl shadow-luxury p-8 text-center"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
<div className="text-red-500 text-5xl mb-4">⚠️</div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<h2 className="text-2xl font-bold text-slate-800 mb-2">Order Not Found</h2>
|
|
|
|
|
|
<p className="text-slate-600 mb-6">{error || 'Unable to retrieve order details'}</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => router.push('/')}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="inline-block px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
Return to Home
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { order, session } = orderDetails;
|
|
|
|
|
|
const totalAmount = order.totalAmount / 100; // Convert cents to dollars
|
|
|
|
|
|
const baseAmount = order.baseAmount / 100;
|
|
|
|
|
|
const processingFee = order.processingFee / 100;
|
|
|
|
|
|
|
|
|
|
|
|
// Use Stripe payment status if available (more accurate for just-completed payments)
|
|
|
|
|
|
// Otherwise fall back to order status
|
|
|
|
|
|
const effectiveStatus = session.paymentStatus === 'paid' ? 'paid' : order.status;
|
|
|
|
|
|
const statusDisplay = getStatusDisplay(effectiveStatus);
|
2025-10-31 22:23:45 +01:00
|
|
|
|
|
|
|
|
|
|
return (
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<>
|
|
|
|
|
|
{/* Print-specific styles */}
|
|
|
|
|
|
<style>{`
|
|
|
|
|
|
@media print {
|
|
|
|
|
|
/* Force print backgrounds and colors */
|
|
|
|
|
|
* {
|
|
|
|
|
|
-webkit-print-color-adjust: exact !important;
|
|
|
|
|
|
print-color-adjust: exact !important;
|
|
|
|
|
|
color-adjust: exact !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Hide non-print elements */
|
|
|
|
|
|
.no-print {
|
|
|
|
|
|
display: none !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Page breaks */
|
|
|
|
|
|
.print-page-break {
|
|
|
|
|
|
page-break-after: always !important;
|
|
|
|
|
|
break-after: page !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Page setup */
|
|
|
|
|
|
@page {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin: 0.3in;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
size: letter;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Main container - optimize for print */
|
|
|
|
|
|
.print-receipt {
|
|
|
|
|
|
max-width: 100% !important;
|
|
|
|
|
|
margin: 0 !important;
|
2025-11-03 15:41:51 +01:00
|
|
|
|
padding: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Aggressive spacing compression */
|
|
|
|
|
|
.p-8, .px-8, .py-8 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
padding: 0.3rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.p-6, .px-6, .py-6 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
padding: 0.3rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.p-5 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
padding: 0.3rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mb-8, .mb-6 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-bottom: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mt-8, .mt-6 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-top: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mb-4 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-bottom: 0.1rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mt-4 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-top: 0.1rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mb-2 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-bottom: 0.08rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Spacing between elements */
|
|
|
|
|
|
.space-y-1 > * + * {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-top: 0.08rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.space-y-3 > * + * {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-top: 0.1rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.space-y-4 > * + * {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
margin-top: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.gap-3 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
gap: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.gap-5 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
gap: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Font size optimization */
|
|
|
|
|
|
.text-4xl {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 1.1rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-3xl {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 1rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-2xl {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.9rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-xl {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.85rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-lg {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.8rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-base {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.75rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-sm {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.7rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-xs {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
font-size: 0.65rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Line height compression */
|
|
|
|
|
|
* {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
line-height: 1.2 !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
animation: none !important;
|
|
|
|
|
|
transition: none !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
h1, h2, h3 {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
line-height: 1.15 !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Logo sizing */
|
|
|
|
|
|
.print-logo {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
max-width: 80px !important;
|
|
|
|
|
|
margin-bottom: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Compact grid layouts */
|
|
|
|
|
|
.grid {
|
2025-11-03 15:41:51 +01:00
|
|
|
|
gap: 0.15rem !important;
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Metadata grid - keep 2 columns but more compact */
|
|
|
|
|
|
.md\\:grid-cols-2 {
|
|
|
|
|
|
display: grid !important;
|
|
|
|
|
|
grid-template-columns: 1fr 1fr !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Make single column items span only 1 column in print */
|
|
|
|
|
|
.md\\:col-span-2 {
|
|
|
|
|
|
grid-column: span 1 !important;
|
|
|
|
|
|
}
|
2025-11-03 15:41:51 +01:00
|
|
|
|
|
|
|
|
|
|
/* Reduce rounded corners for print to save space */
|
|
|
|
|
|
.rounded-3xl, .rounded-2xl, .rounded-xl {
|
|
|
|
|
|
border-radius: 0.25rem !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Compact the header gradient section */
|
|
|
|
|
|
.bg-gradient-to-br {
|
|
|
|
|
|
padding-top: 0.3rem !important;
|
|
|
|
|
|
padding-bottom: 0.3rem !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reduce shadow to save ink/space */
|
|
|
|
|
|
.shadow-2xl, .shadow-xl, .shadow-lg {
|
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
|
}
|
2025-11-02 19:13:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
`}</style>
|
|
|
|
|
|
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-cyan-50 flex items-center justify-center p-4 sm:p-6">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ duration: 0.5 }}
|
|
|
|
|
|
className="max-w-full sm:max-w-4xl lg:max-w-5xl w-full print-receipt"
|
|
|
|
|
|
>
|
|
|
|
|
|
{/* Receipt Container - Page 1 */}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-white rounded-3xl shadow-2xl overflow-hidden print:rounded-none print:shadow-none print-page-break">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
{/* Header with Logo */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: -20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ delay: 0.1 }}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="bg-gradient-to-br from-cyan-500 via-blue-500 to-indigo-600 p-8 text-center"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
<img
|
|
|
|
|
|
src="/puffinOffset.webp"
|
|
|
|
|
|
alt="Puffin Offset"
|
|
|
|
|
|
className="h-24 mx-auto mb-4 print-logo"
|
|
|
|
|
|
/>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<h1 className="text-3xl md:text-4xl font-bold text-white mb-2">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
Order Confirmed
|
|
|
|
|
|
</h1>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<p className="text-cyan-50 text-lg">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
Thank you for your carbon offset purchase
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
|
2025-11-03 15:05:11 +01:00
|
|
|
|
{/* Success Badge */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ scale: 0 }}
|
|
|
|
|
|
animate={{ scale: 1 }}
|
|
|
|
|
|
transition={{ delay: 0.2, type: 'spring', stiffness: 200 }}
|
|
|
|
|
|
className="flex justify-center -mt-8 mb-6 no-print"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="bg-green-500 text-white rounded-full p-6 shadow-xl border-4 border-white">
|
|
|
|
|
|
<svg className="w-12 h-12" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
|
|
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M5 13l4 4L19 7" />
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
|
2025-11-02 19:13:15 +01:00
|
|
|
|
{/* Order Details Section */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ delay: 0.3 }}
|
|
|
|
|
|
className="px-8 py-6"
|
|
|
|
|
|
>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<h2 className="text-2xl font-bold text-slate-800 mb-6 pb-3 border-b-2 border-slate-200">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
Order Summary
|
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="space-y-1 mb-6">
|
|
|
|
|
|
{/* Carbon Offset - Highlighted */}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-gradient-to-r from-emerald-50 to-teal-50 rounded-xl p-6 mb-4 border-l-4 border-emerald-500">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
|
|
<div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-sm text-emerald-700 font-medium uppercase tracking-wide">Carbon Offset</span>
|
|
|
|
|
|
<p className="text-3xl font-bold text-emerald-900 mt-1">{order.tons} tons CO₂</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
</div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="text-emerald-600">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<Leaf className="w-16 h-16" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Pricing Breakdown */}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-slate-50 rounded-lg p-5 my-4 space-y-3">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<div className="flex justify-between items-center">
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-slate-700">Offset Cost</span>
|
|
|
|
|
|
<span className="text-slate-900 font-semibold">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
${formatCurrency(baseAmount)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex justify-between items-center">
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-slate-700">Processing Fee (3%)</span>
|
|
|
|
|
|
<span className="text-slate-900 font-semibold">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
${formatCurrency(processingFee)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="border-t-2 border-slate-300 pt-3 mt-3">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<div className="flex justify-between items-center">
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-slate-800 font-bold text-lg">Total Paid</span>
|
|
|
|
|
|
<span className="text-blue-600 font-bold text-3xl">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
${formatCurrency(totalAmount)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Order Metadata */}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-gradient-to-r from-slate-50 to-blue-50 rounded-lg p-5 space-y-4">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-5">
|
|
|
|
|
|
{/* Payment ID (Stripe) */}
|
|
|
|
|
|
<div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-xs uppercase tracking-wide text-slate-500 font-semibold">Payment ID</span>
|
|
|
|
|
|
<p className="text-slate-800 font-mono text-xs mt-1 break-all">{order.stripeSessionId}</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Offsetting Order ID (Wren) - Only show if fulfilled */}
|
|
|
|
|
|
{order.wrenOrderId && (
|
|
|
|
|
|
<div>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-xs uppercase tracking-wide text-slate-500 font-semibold">Offsetting Order ID</span>
|
|
|
|
|
|
<p className="text-slate-800 font-mono text-xs mt-1 break-all">{order.wrenOrderId}</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
<div className={order.wrenOrderId ? '' : 'md:col-start-2'}>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-xs uppercase tracking-wide text-slate-500 font-semibold">Status</span>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<p className="mt-2">
|
|
|
|
|
|
<span className={`inline-block px-4 py-1.5 rounded-full text-sm font-bold ${statusDisplay.className}`}>
|
|
|
|
|
|
{statusDisplay.label}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{session.customerEmail && (
|
|
|
|
|
|
<div className="md:col-span-2">
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-xs uppercase tracking-wide text-slate-500 font-semibold">Email</span>
|
|
|
|
|
|
<p className="text-slate-800 font-medium mt-1">{session.customerEmail}</p>
|
2025-11-02 19:13:15 +01:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
<div className="md:col-span-2">
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<span className="text-xs uppercase tracking-wide text-slate-500 font-semibold">Date</span>
|
|
|
|
|
|
<p className="text-slate-800 font-medium mt-1">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
{new Date().toLocaleDateString('en-US', {
|
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
|
month: 'long',
|
|
|
|
|
|
day: 'numeric'
|
|
|
|
|
|
})}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Portfolio Distribution Chart - Page 2 */}
|
|
|
|
|
|
{orderDetails.order.portfolio?.projects && orderDetails.order.portfolio.projects.length > 0 && (
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ delay: 0.35 }}
|
|
|
|
|
|
className="mt-6"
|
|
|
|
|
|
>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-white rounded-3xl shadow-2xl overflow-hidden p-8 print:rounded-none print:shadow-none print:border-none print-page-break">
|
|
|
|
|
|
<h2 className="text-2xl font-bold text-slate-800 mb-2 text-center print:text-xl">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
Your Carbon Offset Distribution
|
|
|
|
|
|
</h2>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<p className="text-slate-600 text-center mb-8 print:text-sm print:mb-4">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
Your {order.tons} tons of CO₂ offsets are distributed across these verified projects:
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<RechartsPortfolioPieChart
|
|
|
|
|
|
projects={orderDetails.order.portfolio.projects}
|
|
|
|
|
|
totalTons={order.tons}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Impact Comparisons - Page 3 */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ delay: 0.4 }}
|
|
|
|
|
|
className="mt-6"
|
|
|
|
|
|
>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-gradient-to-br from-emerald-600 via-teal-600 to-cyan-600 rounded-3xl p-8 shadow-2xl print:rounded-none print:shadow-none print:bg-white print:border print:border-gray-300 print-page-break">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<CarbonImpactComparison tons={order.tons} variant="success" count={3} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Action Buttons */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
|
transition={{ delay: 0.5 }}
|
|
|
|
|
|
className="flex flex-col sm:flex-row gap-4 justify-center mt-8 no-print"
|
|
|
|
|
|
>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => router.push('/')}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="px-8 py-4 bg-gradient-to-r from-blue-500 to-cyan-500 text-white rounded-xl hover:from-blue-600 hover:to-cyan-600 transition-all hover:shadow-xl font-bold text-center transform hover:scale-105"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
Return to Home
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => router.push('/calculator')}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="px-8 py-4 bg-gradient-to-r from-green-500 to-emerald-500 text-white rounded-xl hover:from-green-600 hover:to-emerald-600 transition-all hover:shadow-xl font-bold text-center transform hover:scale-105"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
Calculate Another Offset
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => window.print()}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="px-8 py-4 bg-white text-slate-700 rounded-xl hover:bg-slate-50 transition-all hover:shadow-xl font-bold border-2 border-slate-300 flex items-center justify-center gap-2 transform hover:scale-105"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
|
|
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z" />
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
Print Receipt
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Confirmation Email Notice */}
|
|
|
|
|
|
{session.customerEmail && (
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
|
transition={{ delay: 0.6 }}
|
|
|
|
|
|
className="text-center mt-6 no-print"
|
|
|
|
|
|
>
|
2025-11-03 15:05:11 +01:00
|
|
|
|
<div className="bg-blue-50 border-l-4 border-blue-500 p-4 rounded-lg inline-block">
|
|
|
|
|
|
<p className="text-blue-800 font-medium">
|
2025-11-02 19:13:15 +01:00
|
|
|
|
<svg className="w-5 h-5 inline mr-2" fill="currentColor" viewBox="0 0 20 20">
|
|
|
|
|
|
<path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" />
|
|
|
|
|
|
<path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" />
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
Confirmation email sent to {session.customerEmail}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Footer */}
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
|
transition={{ delay: 0.7 }}
|
2025-11-03 15:05:11 +01:00
|
|
|
|
className="text-center text-slate-500 text-sm mt-8 pb-6 no-print"
|
2025-11-02 19:13:15 +01:00
|
|
|
|
>
|
|
|
|
|
|
<p>Thank you for making a positive impact on our planet</p>
|
|
|
|
|
|
<p className="mt-2">Questions? Contact us at support@puffinoffset.com</p>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
2025-10-31 22:23:45 +01:00
|
|
|
|
);
|
|
|
|
|
|
}
|