-
+
- |
+ |
- | ${logoWideTag} |
-
+ |
+ ${esc(BRAND.company)}
+ |
+
${opts.headerLabel}
|
|
+ | |
@@ -188,7 +178,7 @@ function buildEmailHtml(opts: {
|
| Total |
-
+ |
${opts.totalHours.toFixed(1)} hrs — ${formatCurrency(opts.totalCost)}
|
@@ -205,16 +195,15 @@ function buildEmailHtml(opts: {
- ${signatureIconCell}
|
-
+
${esc(opts.signature.name)}
-
+
${esc(opts.signature.title)}
-
- ${esc(opts.signature.websiteLabel)}
+
+ ${esc(opts.signature.websiteLabel)}
|
@@ -228,10 +217,17 @@ function buildEmailHtml(opts: {
- |
-
- Open TEN99
-
+ |
+
+ ${esc(BRAND.company)}
+
+
+ ${esc(BRAND.email)}
+ ·
+ ${esc(BRAND.website)}
+ ·
+ ${esc(BRAND.phone)}
+
|
@@ -245,7 +241,7 @@ function buildEmailHtml(opts: {
/* ── Component ───────────────────────────────────────────── */
-export default function EmailComposer({ workItems, clients }: EmailComposerProps) {
+export default function EmailComposer({ workItems, clients, settings }: EmailComposerProps) {
const { id, type } = useParams<{ id: string; type: string }>();
const navigate = useNavigate();
@@ -288,8 +284,8 @@ export default function EmailComposer({ workItems, clients }: EmailComposerProps
? `Invoice — ${item.subject}`
: `Work Order Completed! — ${item.subject}`;
});
- const fromEmail = 'noreply@example.com';
- const fromName = 'Open TEN99';
+ const fromEmail = BRAND.fromEmail;
+ const fromName = BRAND.fromName;
const [greeting, setGreeting] = useState(`Hello ${client?.name ?? ''},`);
const [message, setMessage] = useState(() => {
@@ -429,6 +425,23 @@ export default function EmailComposer({ workItems, clients }: EmailComposerProps
setSendState('sending');
setError(null);
try {
+ // Attach a branded PDF copy of the invoice (invoices only).
+ let pdfBase64: string | undefined;
+ let pdfFilename: string | undefined;
+ if (isInvoice && item && client) {
+ const pdfBytes = await buildChangeOrderPdfBytes(item, client, {
+ companyName: settings.companyName,
+ hourlyRate: settings.hourlyRate,
+ taxRate: settings.invoiceTaxRate,
+ pdfLogoUrl: settings.pdfLogoUrl,
+ invoiceFromAddress: settings.invoiceFromAddress,
+ invoiceNotes: settings.invoiceNotes,
+ invoiceTerms: settings.invoiceTerms,
+ });
+ pdfBase64 = uint8ToBase64(pdfBytes);
+ pdfFilename = `Invoice-${slug(item.subject)}-${(item.id ?? '').slice(0, 6)}.pdf`;
+ }
+
const fn = httpsCallable(functions, 'sendCompletionEmail');
await fn({
to: toEmail,
@@ -438,6 +451,8 @@ export default function EmailComposer({ workItems, clients }: EmailComposerProps
fromEmail,
fromName,
html: currentHtml,
+ pdfBase64,
+ pdfFilename,
});
if (emailType === 'invoice' && item?.id) {
| |