import React from 'react'; import { Trash2 } from 'lucide-react'; export default function QuoteSummary({ items, customer, shippingCost, onShippingChange, onRemoveItem }) { const provinceTaxRates = { 'ON': 0.13, // Ontario (HST) 'QC': 0.05, // Quebec (GST) 'NS': 0.15, // Nova Scotia (HST) 'NB': 0.15, // New Brunswick (HST) 'MB': 0.05, // Manitoba (GST) 'BC': 0.05, // British Columbia (GST) 'PE': 0.15, // Prince Edward Island (HST) 'SK': 0.05, // Saskatchewan (GST) 'AB': 0.05, // Alberta (GST) 'NL': 0.15, // Newfoundland and Labrador (HST) 'NT': 0.05, // Northwest Territories (GST) 'YT': 0.05, // Yukon (GST) 'NU': 0.05 // Nunavut (GST) }; const getTaxRate = () => { const province = customer.province?.toUpperCase().trim(); return provinceTaxRates[province] || 0.13; // Default to 13% if unknown }; const calculateSubtotal = () => { return items.reduce((total, item) => total + (item.Price * item.quantity), 0); }; const subtotal = calculateSubtotal(); const shipping = parseFloat(shippingCost) || 0; const taxRate = getTaxRate(); const tax = (subtotal + shipping) * taxRate; const total = subtotal + shipping + tax; const formatCurrency = (amount) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount); }; if (items.length === 0) { return (

No items added to the quote yet.

); } return (

Quote Summary

{items.map((item, index) => ( ))}
Item ID Description Unit Price Quantity Total Action
{item['Item ID']} {item.Description} {formatCurrency(item.Price)} {item.quantity} {formatCurrency(item.Price * item.quantity)}
Subtotal: {formatCurrency(subtotal)}
Shipping:
$ onShippingChange(e.target.value)} style={{ width: '80px', padding: '0.25rem', fontSize: '1rem', textAlign: 'right' }} />
{formatCurrency(shipping)}
Tax ({(taxRate * 100).toFixed(1)}%): {formatCurrency(tax)}
Total: {formatCurrency(total)}
); }