From 8a5092c56d331cfdccba1bfd23709bcc7b74275c Mon Sep 17 00:00:00 2001 From: Todd Date: Wed, 22 Apr 2026 14:22:42 -0400 Subject: [PATCH] add contact and workorder --- src/App.jsx | 39 ++++++++++++---- src/components/CustomerForm.jsx | 34 ++++++++++++-- src/components/QuoteSummary.jsx | 75 +++++++++++++++++------------- src/components/SavedQuotesList.jsx | 5 +- 4 files changed, 106 insertions(+), 47 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 5fc4ca2..3b74666 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -14,9 +14,11 @@ function App() { const [quoteDate, setQuoteDate] = useState(''); const [savedQuotes, setSavedQuotes] = useState([]); const [shippingCost, setShippingCost] = useState(0); + const [isWorkOrderMode, setIsWorkOrderMode] = useState(false); const [customer, setCustomer] = useState({ name: '', + contactName: '', address: '', city: '', province: '', @@ -29,6 +31,12 @@ function App() { useEffect(() => { generateNewQuoteId(); loadSavedQuotes(); + + const handleAfterPrint = () => { + setIsWorkOrderMode(false); + }; + window.addEventListener('afterprint', handleAfterPrint); + return () => window.removeEventListener('afterprint', handleAfterPrint); }, []); useEffect(() => { @@ -66,8 +74,18 @@ function App() { setQuoteItems(newItems); }; - const handlePrint = () => { - window.print(); + const handlePrintQuote = () => { + setIsWorkOrderMode(false); + setTimeout(() => { + window.print(); + }, 100); + }; + + const handlePrintWorkOrder = () => { + setIsWorkOrderMode(true); + setTimeout(() => { + window.print(); + }, 100); }; const handleSaveQuote = async () => { @@ -144,7 +162,7 @@ function App() { const handleNewQuote = () => { generateNewQuoteId(); - setCustomer({ name: '', address: '', city: '', province: '', postalCode: '', phone: '', email: '' }); + setCustomer({ name: '', contactName: '', address: '', city: '', province: '', postalCode: '', phone: '', email: '' }); setQuoteItems([]); setShippingCost(0); }; @@ -155,7 +173,7 @@ function App() {
Company Logo

Little Beaver Earth Augers

-

Official Quote Generator

+

{isWorkOrderMode ? 'Work Order' : 'Official Quote Generator'}

@@ -165,15 +183,16 @@ function App() {

Quote For:

{customer.name || 'N/A'}

+ {customer.contactName &&

Attn: {customer.contactName}

}

{customer.address || 'N/A'}

{customer.city ? `${customer.city}, ` : ''}{customer.province} {customer.postalCode}

{customer.phone || 'N/A'}

{customer.email || 'N/A'}

-

Quote Details:

+

{isWorkOrderMode ? 'Work Order Details:' : 'Quote Details:'}

Date: {quoteDate}

-

Quote #: {quoteId}

+

{isWorkOrderMode ? 'Work Order #:' : 'Quote #:'} {quoteId}

@@ -181,7 +200,7 @@ function App() {
-

Current Quote: #{quoteId}

+

{isWorkOrderMode ? 'Current Work Order' : 'Current Quote'}: #{quoteId}

@@ -203,6 +222,7 @@ function App() { shippingCost={shippingCost} onShippingChange={setShippingCost} onRemoveItem={handleRemoveItem} + isWorkOrderMode={isWorkOrderMode} /> {/* Action Buttons */} @@ -211,9 +231,12 @@ function App() { - +
)} diff --git a/src/components/CustomerForm.jsx b/src/components/CustomerForm.jsx index 3f9e8bb..a312736 100644 --- a/src/components/CustomerForm.jsx +++ b/src/components/CustomerForm.jsx @@ -53,13 +53,24 @@ export default function CustomerForm({ customer, onChange, savedQuotes = [] }) {
- + +
+
+ +
@@ -87,14 +98,27 @@ export default function CustomerForm({ customer, onChange, savedQuotes = [] }) {
- + > + + + + + + + + + + + + + + +
diff --git a/src/components/QuoteSummary.jsx b/src/components/QuoteSummary.jsx index b029b67..346bbfa 100644 --- a/src/components/QuoteSummary.jsx +++ b/src/components/QuoteSummary.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Trash2 } from 'lucide-react'; -export default function QuoteSummary({ items, customer, shippingCost, onShippingChange, onRemoveItem }) { +export default function QuoteSummary({ items, customer, shippingCost, onShippingChange, onRemoveItem, isWorkOrderMode }) { const provinceTaxRates = { 'ON': 0.13, // Ontario (HST) 'QC': 0.05, // Quebec (GST) @@ -51,17 +51,18 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping return (
-

Quote Summary

+

{isWorkOrderMode ? 'Work Order Summary' : 'Quote Summary'}

- - + {!isWorkOrderMode && } + {!isWorkOrderMode && } - + {!isWorkOrderMode && } + {isWorkOrderMode && } @@ -74,10 +75,16 @@ export default function QuoteSummary({ items, customer, shippingCost, onShipping - - + {!isWorkOrderMode && } + {!isWorkOrderMode && } - + {!isWorkOrderMode && } + {isWorkOrderMode && ( + + )} - +
Item ID DescriptionUnit PriceDiscountUnit PriceDiscountQuantityTotalTotalDoneAction
{item['Item ID']} {item.Description}{formatCurrency(item.Price)}{item.discount ? `${item.discount}%` : '-'}{formatCurrency(item.Price)}{item.discount ? `${item.discount}%` : '-'}{item.quantity}{formatCurrency(finalPrice)}{formatCurrency(finalPrice)} +
+
+
{quote.id} {quote.date}{quote.customer.name || 'N/A'} + {quote.customer.name || 'N/A'} + {quote.customer.contactName &&
Attn: {quote.customer.contactName}
} +
{quote.items.length} {formatCurrency(total)}