| 1 | import { Section, Text } from '@react-email/components' |
| 2 | import { env } from '@/env' |
| 3 | import { |
| 4 | ActionButton, |
| 5 | EmailLayout, |
| 6 | InfoCard, |
| 7 | InfoRow, |
| 8 | text, |
| 9 | } from '../components/layout' |
| 10 | |
| 11 | const baseUrl = env.NEXT_PUBLIC_BASE_URL ?? 'http://localhost:3000' |
| 12 | |
| 13 | interface InvoiceSentEmailProps { |
| 14 | currency: string |
| 15 | dueDate: string |
| 16 | invoiceId: string |
| 17 | invoiceNumber: string |
| 18 | issueDate: string |
| 19 | orgSlug: string |
| 20 | projectName: string |
| 21 | projectSlug: string |
| 22 | recipientName: string |
| 23 | senderName: string |
| 24 | totalAmount: string |
| 25 | } |
| 26 | |
| 27 | export default function InvoiceSentEmail({ |
| 28 | recipientName = 'Jane Smith', |
| 29 | invoiceNumber = 'INV-2026-001', |
| 30 | projectName = 'Website Redesign', |
| 31 | senderName = 'John Doe', |
| 32 | totalAmount = '2,500.00', |
| 33 | currency = 'USD', |
| 34 | dueDate = 'March 30, 2026', |
| 35 | issueDate = 'March 8, 2026', |
| 36 | orgSlug = 'acme', |
| 37 | projectSlug = 'website-redesign', |
| 38 | invoiceId = 'inv_abc123', |
| 39 | }: InvoiceSentEmailProps) { |
| 40 | return ( |
| 41 | <EmailLayout |
| 42 | accentColor='#7c3aed' |
| 43 | heading='You have a new invoice' |
| 44 | preview={`Invoice ${invoiceNumber} — ${currency} ${totalAmount}`} |
| 45 | > |
| 46 | <Text style={text.paragraph}> |
| 47 | Hi {recipientName}, <span style={text.strong}>{senderName}</span> sent |
| 48 | you an invoice for work on{' '} |
| 49 | <span style={text.strong}>{projectName}</span>. |
| 50 | </Text> |
| 51 | <Section style={amountSection}> |
| 52 | <Text style={currencyLabel}>{currency}</Text> |
| 53 | <Text style={{ ...text.large, color: '#18181b' }}>{totalAmount}</Text> |
| 54 | </Section> |
| 55 | <InfoCard> |
| 56 | <InfoRow label='Invoice' value={invoiceNumber} /> |
| 57 | <InfoRow label='Issued' value={issueDate} /> |
| 58 | <InfoRow label='Due' value={dueDate} /> |
| 59 | </InfoCard> |
| 60 | <ActionButton |
| 61 | href={`${baseUrl}/${orgSlug}/${projectSlug}/invoices/${invoiceId}`} |
| 62 | > |
| 63 | View Invoice |
| 64 | </ActionButton> |
| 65 | <Text style={text.muted}> |
| 66 | If you have questions about this invoice, you can start a thread |
| 67 | directly on the invoice page. |
| 68 | </Text> |
| 69 | </EmailLayout> |
| 70 | ) |
| 71 | } |
| 72 | |
| 73 | const amountSection = { |
| 74 | textAlign: 'center' as const, |
| 75 | padding: '20px 0 8px', |
| 76 | } |
| 77 | |
| 78 | const currencyLabel = { |
| 79 | fontSize: '13px', |
| 80 | color: '#71717a', |
| 81 | fontWeight: '500' as const, |
| 82 | margin: '0 0 4px', |
| 83 | textAlign: 'center' as const, |
| 84 | } |