diff --git a/quotes.json b/quotes.json index 48a9ade..011bd31 100644 --- a/quotes.json +++ b/quotes.json @@ -482,5 +482,35 @@ } ], "shippingCost": 0 + }, + { + "id": 8071, + "date": "March 24, 2026", + "customer": { + "name": "LOCATION WINDSOR", + "address": "89 RUE PRINCIPALE S", + "city": "WINDSOR", + "province": "QC", + "postalCode": "J1S 2B9", + "phone": "819 845 7874", + "email": "martin.dion@locationwindsor.com" + }, + "items": [ + { + "Item ID": "4X36-SSS", + "Description": "Auger, Snap-on", + "Price": 383.36166000000003, + "quantity": 1, + "discount": 0 + }, + { + "Item ID": "6X36-SSP", + "Description": "Auger, Snap-on, Pengo Style", + "Price": 577.8892350000001, + "quantity": 2, + "discount": 0 + } + ], + "shippingCost": 0 } ] \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 6dfc502..5fc4ca2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -189,7 +189,7 @@ function App() { {/* Customer Form */}
- +
{/* Item Selector */} diff --git a/src/components/CustomerForm.jsx b/src/components/CustomerForm.jsx index d70dbe4..3f9e8bb 100644 --- a/src/components/CustomerForm.jsx +++ b/src/components/CustomerForm.jsx @@ -1,14 +1,56 @@ import React from 'react'; -export default function CustomerForm({ customer, onChange }) { +export default function CustomerForm({ customer, onChange, savedQuotes = [] }) { const handleChange = (e) => { const { name, value } = e.target; onChange({ ...customer, [name]: value }); }; + const uniqueCustomers = []; + const seenNames = new Set(); + + savedQuotes.forEach(quote => { + const c = quote.customer; + if (c && c.name && c.name.trim() !== '') { + const normalized = c.name.trim().toLowerCase(); + if (!seenNames.has(normalized)) { + seenNames.add(normalized); + uniqueCustomers.push(c); + } + } + }); + + const handleSelectExisting = (e) => { + if (e.target.value === "") return; + const selected = uniqueCustomers[parseInt(e.target.value, 10)]; + if (selected) { + onChange({ ...customer, ...selected }); + } + // reset the select back to default after choosing + e.target.value = ""; + }; + return (
-

Customer Information

+
+

Customer Information

+ {uniqueCustomers.length > 0 && ( +
+ + +
+ )} +