| 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 ProjectDueDateReminderEmailProps { |
| 14 | daysRemaining: number |
| 15 | dueDate: string |
| 16 | organizationName: string |
| 17 | orgSlug: string |
| 18 | projectName: string |
| 19 | projectSlug: string |
| 20 | recipientName: string |
| 21 | } |
| 22 | |
| 23 | export default function ProjectDueDateReminderEmail({ |
| 24 | recipientName = 'John Doe', |
| 25 | projectName = 'Website Redesign', |
| 26 | organizationName = 'Acme Studio', |
| 27 | dueDate = 'March 15, 2026', |
| 28 | daysRemaining = 3, |
| 29 | orgSlug = 'acme', |
| 30 | projectSlug = 'website-redesign', |
| 31 | }: ProjectDueDateReminderEmailProps) { |
| 32 | const isOverdue = daysRemaining < 0 |
| 33 | const absDays = Math.abs(daysRemaining) |
| 34 | const accentColor = isOverdue ? '#ef4444' : '#f59e0b' |
| 35 | |
| 36 | const countdownText = isOverdue |
| 37 | ? `${absDays} day${absDays === 1 ? '' : 's'} overdue` |
| 38 | : `${daysRemaining} day${daysRemaining === 1 ? '' : 's'} remaining` |
| 39 | |
| 40 | return ( |
| 41 | <EmailLayout |
| 42 | accentColor={accentColor} |
| 43 | heading={isOverdue ? 'Project is overdue' : 'Due date approaching'} |
| 44 | preview={`${projectName}: ${countdownText}`} |
| 45 | > |
| 46 | <Text style={text.paragraph}> |
| 47 | Hi {recipientName}, <span style={text.strong}>{projectName}</span> in{' '} |
| 48 | {organizationName} {isOverdue ? 'was' : 'is'} due on{' '} |
| 49 | <span style={text.strong}>{dueDate}</span>. |
| 50 | </Text> |
| 51 | <Section style={countdownSection}> |
| 52 | <Text style={{ ...text.large, color: accentColor }}>{absDays}</Text> |
| 53 | <Text style={countdownLabel}> |
| 54 | {isOverdue |
| 55 | ? `day${absDays === 1 ? '' : 's'} overdue` |
| 56 | : `day${daysRemaining === 1 ? '' : 's'} remaining`} |
| 57 | </Text> |
| 58 | </Section> |
| 59 | <InfoCard> |
| 60 | <InfoRow label='Project' value={projectName} /> |
| 61 | <InfoRow label='Due date' value={dueDate} /> |
| 62 | <InfoRow label='Workspace' value={organizationName} /> |
| 63 | </InfoCard> |
| 64 | <ActionButton |
| 65 | color={accentColor} |
| 66 | href={`${baseUrl}/${orgSlug}/${projectSlug}`} |
| 67 | > |
| 68 | View Project |
| 69 | </ActionButton> |
| 70 | </EmailLayout> |
| 71 | ) |
| 72 | } |
| 73 | |
| 74 | const countdownSection = { |
| 75 | textAlign: 'center' as const, |
| 76 | padding: '16px 0 8px', |
| 77 | } |
| 78 | |
| 79 | const countdownLabel = { |
| 80 | fontSize: '13px', |
| 81 | color: '#71717a', |
| 82 | fontWeight: '500' as const, |
| 83 | margin: '4px 0 0', |
| 84 | textAlign: 'center' as const, |
| 85 | textTransform: 'uppercase' as const, |
| 86 | letterSpacing: '0.5px', |
| 87 | } |