81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { TransactionalScaffold } from "./shared.js";
|
|
import { InfoBox } from "../_layout/InfoBox.js";
|
|
import type { MailBrand } from "../_layout/theme.js";
|
|
|
|
/**
|
|
* InvoiceSentEmail — notifies a customer that a invoice PDF
|
|
* has been issued. CTA points to the hosted-invoice URL so the user
|
|
* can download the PDF without authenticating.
|
|
*/
|
|
export interface InvoiceSentEmailProps {
|
|
readonly brand: MailBrand;
|
|
readonly recipientName?: string;
|
|
readonly invoiceNumber: string;
|
|
readonly amountFormatted: string;
|
|
readonly issueDate: string;
|
|
readonly dueDate?: string;
|
|
readonly actionUrl: string;
|
|
readonly unsubscribeUrl?: string;
|
|
readonly subject?: string;
|
|
readonly eyebrow?: string;
|
|
readonly titleText?: string;
|
|
readonly intro?: string;
|
|
readonly actionLabel?: string;
|
|
readonly fieldLabels?: {
|
|
readonly invoiceNumber?: string;
|
|
readonly amount?: string;
|
|
readonly issued?: string;
|
|
readonly due?: string;
|
|
};
|
|
readonly signoffThanks?: string;
|
|
}
|
|
|
|
export function InvoiceSentEmail({
|
|
brand,
|
|
recipientName,
|
|
invoiceNumber,
|
|
amountFormatted,
|
|
issueDate,
|
|
dueDate,
|
|
actionUrl,
|
|
unsubscribeUrl,
|
|
subject,
|
|
eyebrow,
|
|
titleText,
|
|
intro,
|
|
actionLabel,
|
|
fieldLabels,
|
|
signoffThanks,
|
|
}: InvoiceSentEmailProps) {
|
|
const resolvedSubject = subject ?? `Invoice ${invoiceNumber} from ${brand.productName}`;
|
|
const resolvedTitle = titleText ?? (recipientName ? `Hello, ${recipientName}!` : "Your invoice is ready");
|
|
const resolvedIntro = intro ?? `Your invoice ${invoiceNumber} for ${amountFormatted} is now available.`;
|
|
return (
|
|
<TransactionalScaffold
|
|
brand={brand}
|
|
subject={resolvedSubject}
|
|
eyebrow={eyebrow ?? "Invoice"}
|
|
title={resolvedTitle}
|
|
intro={resolvedIntro}
|
|
actionUrl={actionUrl}
|
|
actionLabel={actionLabel ?? "View invoice PDF"}
|
|
unsubscribeUrl={unsubscribeUrl}
|
|
signoffThanks={signoffThanks}
|
|
>
|
|
<InfoBox brand={brand}>
|
|
<strong>{fieldLabels?.invoiceNumber ?? "Invoice number:"}</strong> {invoiceNumber}
|
|
<br />
|
|
<strong>{fieldLabels?.amount ?? "Amount:"}</strong> {amountFormatted}
|
|
<br />
|
|
<strong>{fieldLabels?.issued ?? "Issued:"}</strong> {issueDate}
|
|
{dueDate ? (
|
|
<>
|
|
<br />
|
|
<strong>{fieldLabels?.due ?? "Due:"}</strong> {dueDate}
|
|
</>
|
|
) : null}
|
|
</InfoBox>
|
|
</TransactionalScaffold>
|
|
);
|
|
}
|