import { SUPPORT_EMAIL } from '@documenso/lib/constants/app'; import { msg } from '@lingui/core/macro'; import { useLingui } from '@lingui/react'; import { Trans } from '@lingui/react/macro'; import { match } from 'ts-pattern'; import { Body, Container, Head, Hr, Html, Preview, Section, Text } from '../components'; import { TemplateBrandingLogo } from '../template-components/template-branding-logo'; import { TemplateFooter } from '../template-components/template-footer'; export type OrganisationLimitAlertEmailProps = { assetBaseUrl: string; organisationName: string; counter: 'document' | 'email' | 'api'; kind: 'rateLimit' | 'quota' | 'quotaNearing'; period: string; }; export const OrganisationLimitAlertEmailTemplate = ({ assetBaseUrl = 'http://localhost:3002', organisationName = 'Organisation Name', counter = 'email', kind = 'quota', period = '2026-05', }: OrganisationLimitAlertEmailProps) => { const { _ } = useLingui(); const previewText = kind === 'quotaNearing' ? msg`Approaching Your Plan Limits` : msg`Organisation Review Required`; return ( {_(previewText)}
{kind === 'quotaNearing' ? ( Approaching Your Plan Limits ) : ( Organisation Review Required )}
{organisationName}
{match(kind) .with('quota', () => ( {match(counter) .with('document', () => ( We've noticed document activity on your account that exceeds the fair use limits of your current plan. As a precaution, new document activity has been temporarily paused pending review. )) .with('email', () => ( We've noticed email sending activity on your account that exceeds the fair use limits of your current plan. As a precaution, new email activity has been temporarily paused pending review. )) .with('api', () => ( We've noticed API activity on your account that exceeds the fair use limits of your current plan. As a precaution, new API activity has been temporarily paused pending review. )) .exhaustive()} )) .with('rateLimit', () => ( {match(counter) .with('document', () => ( Your organisation is generating documents faster than normal, so some requests are being temporarily throttled. )) .with('email', () => ( Your organisation is generating emails faster than normal, so some requests are being temporarily throttled. )) .with('api', () => ( Your organisation is generating API requests faster than normal, so some requests are being temporarily throttled. )) .exhaustive()} )) .with('quotaNearing', () => ( {match(counter) .with('document', () => ( Your organisation is nearing its fair use limits for creating documents on your current plan. Once the limit is reached, new document activity will be temporarily paused. )) .with('email', () => ( Your organisation is nearing its fair use limits for sending email on your current plan. Once the limit is reached, new email activity will be temporarily paused. )) .with('api', () => ( Your organisation is nearing its fair use limits for making API requests on your current plan. Once the limit is reached, new API activity will be temporarily paused. )) .exhaustive()} )) .exhaustive()} {kind === 'quotaNearing' ? ( If you expect to need higher limits, please contact support at {SUPPORT_EMAIL} and we will review your account. ) : ( Please contact support at {SUPPORT_EMAIL} and we will review your account. )}

); }; export default OrganisationLimitAlertEmailTemplate;