```jsx import React from 'react'; import { MapPin, Box, Truck, Info } from 'lucide-react'; // TypeScript interfaces for our data structures interface Address { fullName: string; phoneNumber: string; street: string; city: string; state: string; country: string; zipCode: string; } interface OrderItem { id: string; name: string; price: number; quantity: number; image: string; size?: string; color?: string; } interface ShippingMethod { id: string; name: string; price: number; estimatedDeliveryWindow: { from: string; to: string; }; } interface CheckoutPageProps { shippingAddress: Address; orderItems: OrderItem[]; shippingMethods: ShippingMethod[]; selectedShippingMethod: string; onShippingMethodChange: (id: string) => void; onEditAddress: () => void; onViewOrderDetails: () => void; } export default function CheckoutPage({ shippingAddress, orderItems, shippingMethods, selectedShippingMethod, onShippingMethodChange, onEditAddress, onViewOrderDetails, }: CheckoutPageProps) { // Calculate order summary const subtotal = orderItems.reduce((sum, item) => sum + (item.price * item.quantity), 0); const selectedShipping = shippingMethods.find(method => method.id === selectedShippingMethod); const shippingFee = selectedShipping?.price || 0; const salesTax = subtotal * 0.0825; // Example tax rate of 8.25% const total = subtotal + shippingFee + salesTax; return (
{shippingAddress.fullName}
{shippingAddress.phoneNumber}
{shippingAddress.street}, {shippingAddress.city}, {shippingAddress.state}, {shippingAddress.country}, {shippingAddress.zipCode}
{item.size && `Size: ${item.size}`} {item.color && ` • Color: ${item.color}`}
Quantity: {item.quantity}
${(item.price * item.quantity).toFixed(2)}
Total Items: {orderItems.reduce((sum, item) => sum + item.quantity, 0)}
Estimated Delivery Window: {method.estimatedDeliveryWindow.from} - {method.estimatedDeliveryWindow.to}