|
| 1 | +import { Link, Section, Text } from '@react-email/components' |
| 2 | +import { baseStyles, colors, typography } from '@/components/emails/_styles' |
| 3 | +import { proFeatures } from '@/components/emails/billing/constants' |
| 4 | +import { EmailLayout } from '@/components/emails/components' |
| 5 | +import { dollarsToCredits } from '@/lib/billing/credits/conversion' |
| 6 | +import { getBrandConfig } from '@/ee/whitelabeling' |
| 7 | + |
| 8 | +interface CreditsExhaustedEmailProps { |
| 9 | + userName?: string |
| 10 | + limit: number |
| 11 | + upgradeLink: string |
| 12 | +} |
| 13 | + |
| 14 | +export function CreditsExhaustedEmail({ |
| 15 | + userName, |
| 16 | + limit, |
| 17 | + upgradeLink, |
| 18 | +}: CreditsExhaustedEmailProps) { |
| 19 | + const brand = getBrandConfig() |
| 20 | + |
| 21 | + return ( |
| 22 | + <EmailLayout |
| 23 | + preview={`You've used all ${dollarsToCredits(limit).toLocaleString()} of your free ${brand.name} credits`} |
| 24 | + showUnsubscribe={true} |
| 25 | + > |
| 26 | + <Text style={{ ...baseStyles.paragraph, marginTop: 0 }}> |
| 27 | + {userName ? `Hi ${userName},` : 'Hi,'} |
| 28 | + </Text> |
| 29 | + |
| 30 | + <Text style={baseStyles.paragraph}> |
| 31 | + You've used all <strong>{dollarsToCredits(limit).toLocaleString()}</strong> of your |
| 32 | + free credits on {brand.name}. Your workflows are paused until you upgrade. |
| 33 | + </Text> |
| 34 | + |
| 35 | + <Section |
| 36 | + style={{ |
| 37 | + backgroundColor: '#f8faf9', |
| 38 | + border: `1px solid ${colors.brandTertiary}20`, |
| 39 | + borderRadius: '8px', |
| 40 | + padding: '16px 20px', |
| 41 | + margin: '16px 0', |
| 42 | + }} |
| 43 | + > |
| 44 | + <Text |
| 45 | + style={{ |
| 46 | + fontSize: '14px', |
| 47 | + fontWeight: 600, |
| 48 | + color: colors.brandTertiary, |
| 49 | + fontFamily: typography.fontFamily, |
| 50 | + margin: '0 0 12px 0', |
| 51 | + textTransform: 'uppercase' as const, |
| 52 | + letterSpacing: '0.5px', |
| 53 | + }} |
| 54 | + > |
| 55 | + Pro includes |
| 56 | + </Text> |
| 57 | + <table style={{ width: '100%', borderCollapse: 'collapse' }}> |
| 58 | + <tbody> |
| 59 | + {proFeatures.map((feature, i) => ( |
| 60 | + <tr key={i}> |
| 61 | + <td |
| 62 | + style={{ |
| 63 | + padding: '6px 0', |
| 64 | + fontSize: '15px', |
| 65 | + fontWeight: 600, |
| 66 | + color: colors.textPrimary, |
| 67 | + fontFamily: typography.fontFamily, |
| 68 | + width: '45%', |
| 69 | + }} |
| 70 | + > |
| 71 | + {feature.label} |
| 72 | + </td> |
| 73 | + <td |
| 74 | + style={{ |
| 75 | + padding: '6px 0', |
| 76 | + fontSize: '14px', |
| 77 | + color: colors.textMuted, |
| 78 | + fontFamily: typography.fontFamily, |
| 79 | + }} |
| 80 | + > |
| 81 | + {feature.desc} |
| 82 | + </td> |
| 83 | + </tr> |
| 84 | + ))} |
| 85 | + </tbody> |
| 86 | + </table> |
| 87 | + </Section> |
| 88 | + |
| 89 | + <Link href={upgradeLink} style={{ textDecoration: 'none' }}> |
| 90 | + <Text style={baseStyles.button}>Upgrade to Pro</Text> |
| 91 | + </Link> |
| 92 | + |
| 93 | + <div style={baseStyles.divider} /> |
| 94 | + |
| 95 | + <Text style={{ ...baseStyles.footerText, textAlign: 'left' }}> |
| 96 | + One-time notification when free credits are exhausted. |
| 97 | + </Text> |
| 98 | + </EmailLayout> |
| 99 | + ) |
| 100 | +} |
| 101 | + |
| 102 | +export default CreditsExhaustedEmail |
0 commit comments