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() {
Official Quote Generator
+{isWorkOrderMode ? 'Work Order' : 'Official Quote Generator'}
{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'}
Date: {quoteDate}
-Quote #: {quoteId}
+{isWorkOrderMode ? 'Work Order #:' : 'Quote #:'} {quoteId}
| Item ID | Description | -Unit Price | -Discount | + {!isWorkOrderMode &&Unit Price | } + {!isWorkOrderMode &&Discount | }Quantity | -Total | + {!isWorkOrderMode &&Total | } + {isWorkOrderMode &&Done | }Action | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {item['Item ID']} | {item.Description} | -{formatCurrency(item.Price)} | -{item.discount ? `${item.discount}%` : '-'} | + {!isWorkOrderMode &&{formatCurrency(item.Price)} | } + {!isWorkOrderMode &&{item.discount ? `${item.discount}%` : '-'} | }{item.quantity} | -{formatCurrency(finalPrice)} | + {!isWorkOrderMode &&{formatCurrency(finalPrice)} | } + {isWorkOrderMode && ( ++ + + | + )}
-
- Subtotal:
- {formatCurrency(subtotal)}
-
-
- Shipping:
-
);
}
diff --git a/src/components/SavedQuotesList.jsx b/src/components/SavedQuotesList.jsx
index eeb48f0..343ee88 100644
--- a/src/components/SavedQuotesList.jsx
+++ b/src/components/SavedQuotesList.jsx
@@ -35,7 +35,10 @@ export default function SavedQuotesList({ savedQuotes, onLoadQuote, onDeleteQuot
- $
- onShippingChange(e.target.value)}
- style={{ width: '80px', padding: '0.25rem', fontSize: '1rem', textAlign: 'right' }}
- />
+ {!isWorkOrderMode && (
+
+ )}
+
-
+ 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)}
- {formatCurrency(shipping)}
- Tax ({(taxRate * 100).toFixed(1)}%):
- {formatCurrency(tax)}
-
-
- Total:
- {formatCurrency(total)}
-
- {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)} |
| |