mirror of
https://github.com/soconnor0919/beenvoice.git
synced 2026-05-08 09:38:55 -04:00
refactor: remove InvoiceView component and update related email and invoice handling
- Deleted the InvoiceView component to streamline the codebase. - Updated EmailPreview and SendEmailDialog components to include currency and notes fields. - Enhanced invoice-form to handle default hourly rates and improved item mapping. - Refactored email template generation to include notes and currency formatting. - Adjusted API routers for invoices to calculate totals and handle notes and currency correctly.
This commit is contained in:
@@ -6,6 +6,7 @@ interface InvoiceEmailTemplateProps {
|
||||
status: string;
|
||||
totalAmount: number;
|
||||
taxRate: number;
|
||||
currency?: string | null;
|
||||
notes?: string | null;
|
||||
client: {
|
||||
name: string;
|
||||
@@ -57,10 +58,22 @@ export function generateInvoiceEmailTemplate({
|
||||
const formatCurrency = (amount: number) => {
|
||||
return new Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
currency: invoice.currency ?? "USD",
|
||||
}).format(amount);
|
||||
};
|
||||
|
||||
const escapeHtml = (value: string) =>
|
||||
value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
|
||||
const formattedNotes = invoice.notes?.trim()
|
||||
? escapeHtml(invoice.notes).replace(/\n/g, "<br>")
|
||||
: "";
|
||||
|
||||
const getTimeOfDayGreeting = () => {
|
||||
const hour = new Date().getHours();
|
||||
if (hour < 12) return "Good morning";
|
||||
@@ -459,7 +472,16 @@ export function generateInvoiceEmailTemplate({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
${
|
||||
formattedNotes
|
||||
? `<div class="invoice-card">
|
||||
<div class="invoice-summary">
|
||||
<div class="invoice-number" style="font-size: 18px;">Notes</div>
|
||||
</div>
|
||||
<div class="message" style="margin-bottom: 0;">${formattedNotes}</div>
|
||||
</div>`
|
||||
: ""
|
||||
}
|
||||
|
||||
<div class="attachment-notice">
|
||||
<div class="attachment-icon"></div>
|
||||
@@ -540,7 +562,15 @@ Subtotal: ${formatCurrency(subtotal)}${
|
||||
}
|
||||
Total: ${formatCurrency(total)}
|
||||
|
||||
|
||||
${
|
||||
invoice.notes?.trim()
|
||||
? `
|
||||
NOTES
|
||||
═══════════════
|
||||
${invoice.notes.trim()}
|
||||
`
|
||||
: ""
|
||||
}
|
||||
|
||||
ATTACHMENT
|
||||
═══════════════
|
||||
|
||||
Reference in New Issue
Block a user