diff --git a/index.html b/index.html index dca331a..e5cc337 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + LB Quote Generator diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000..526e89c Binary files /dev/null and b/public/favicon.png differ diff --git a/quotes.json b/quotes.json index 92ec7f1..48a9ade 100644 --- a/quotes.json +++ b/quotes.json @@ -460,5 +460,27 @@ } ], "shippingCost": 0 + }, + { + "id": 2908, + "date": "March 20, 2026", + "customer": { + "name": "test", + "address": "", + "city": "", + "province": "on", + "postalCode": "", + "phone": "", + "email": "" + }, + "items": [ + { + "Item ID": "MDL-5H2", + "Description": "Earth Drill, 5.5HP Honda, 20:1Transmission", + "Price": 4674.3552899999995, + "quantity": 1 + } + ], + "shippingCost": 0 } ] \ No newline at end of file diff --git a/src/components/ItemSelector.jsx b/src/components/ItemSelector.jsx index 92a57a9..874f75d 100644 --- a/src/components/ItemSelector.jsx +++ b/src/components/ItemSelector.jsx @@ -4,21 +4,27 @@ import { Plus } from 'lucide-react'; export default function ItemSelector({ items, onAddItem }) { const [selectedItemIndex, setSelectedItemIndex] = useState(''); const [quantity, setQuantity] = useState(1); + const [discount, setDiscount] = useState(''); const handleAdd = () => { if (selectedItemIndex !== '' && quantity > 0) { const selectedItem = items[selectedItemIndex]; - onAddItem({ ...selectedItem, quantity: parseInt(quantity, 10) }); + onAddItem({ + ...selectedItem, + quantity: parseInt(quantity, 10), + discount: parseFloat(discount) || 0 + }); setSelectedItemIndex(''); setQuantity(1); + setDiscount(''); } }; return (

Add Items to Quote

-
-
+
+
setDiscount(e.target.value)} + placeholder="0" + /> +
+
setQuantity(e.target.value)} />
-
diff --git a/src/components/QuoteSummary.jsx b/src/components/QuoteSummary.jsx index 8dc8245..b029b67 100644 --- a/src/components/QuoteSummary.jsx +++ b/src/components/QuoteSummary.jsx @@ -24,7 +24,11 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping }; const calculateSubtotal = () => { - return items.reduce((total, item) => total + (item.Price * item.quantity), 0); + return items.reduce((total, item) => { + const itemTotal = item.Price * item.quantity; + const discountAmount = itemTotal * ((item.discount || 0) / 100); + return total + (itemTotal - discountAmount); + }, 0); }; const subtotal = calculateSubtotal(); @@ -55,30 +59,37 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping Item ID Description Unit Price + Discount Quantity Total Action - {items.map((item, index) => ( - - {item['Item ID']} - {item.Description} - {formatCurrency(item.Price)} - {item.quantity} - {formatCurrency(item.Price * item.quantity)} - - - - - ))} + {items.map((item, index) => { + const itemTotal = item.Price * item.quantity; + const discountAmount = itemTotal * ((item.discount || 0) / 100); + const finalPrice = itemTotal - discountAmount; + return ( + + {item['Item ID']} + {item.Description} + {formatCurrency(item.Price)} + {item.discount ? `${item.discount}%` : '-'} + {item.quantity} + {formatCurrency(finalPrice)} + + + + + ); + })}