Skip to content

The open alternative to Salesforce, designed for AI.

2.4 KB
Raw Blame
import { Trans } from '@lingui/react';
import { BaseEmail } from 'src/components/BaseEmail';
import { CallToAction } from 'src/components/CallToAction';
import { MainText } from 'src/components/MainText';
import { Title } from 'src/components/Title';
import { createI18nInstance } from 'src/utils/i18n.utils';
import { type APP_LOCALES } from 'twenty-shared/translations';

type BillingTrialEndingEmailProps = {
  userName: string;
  workspaceDisplayName: string | undefined;
  trialEndsAt: Date;
  dataRetentionDays: number;
  link: string;
  locale: keyof typeof APP_LOCALES;
};

// Sent the day before a cardless trial ends; the risk is data loss, not a surprise charge.
export const BillingTrialEndingEmail = ({
  userName,
  workspaceDisplayName,
  trialEndsAt,
  dataRetentionDays,
  link,
  locale,
}: BillingTrialEndingEmailProps) => {
  const i18n = createI18nInstance(locale);
  const formattedDate = i18n.date(trialEndsAt, {
    day: 'numeric',
    month: 'long',
    year: 'numeric',
  });

  return (
    <BaseEmail width={333} locale={locale}>
      <Title value={i18n._('Your trial is ending soon')} />
      <MainText>
        {userName?.length > 1 ? (
          <Trans id="Hi {userName}," values={{ userName }} />
        ) : (
          <Trans id="Hello," />
        )}
        <br />
        <br />
        <Trans
          id="Your free trial of <0>{workspaceDisplayName}</0> ends on {formattedDate}."
          values={{ workspaceDisplayName, formattedDate }}
          components={{ 0: <b /> }}
        />
        <br />
        <br />
        <Trans id="To keep your workspace and everything you've built, add a payment method and pick a plan." />
        <br />
        <br />
        <Trans
          id="If you do nothing, we'll pause your workspace and keep your data safe for {dataRetentionDays} days in case you change your mind — no card will be charged."
          values={{ dataRetentionDays }}
        />
      </MainText>
      <br />
      <CallToAction href={link} value={i18n._('Add a payment method')} />
      <br />
      <br />
    </BaseEmail>
  );
};

BillingTrialEndingEmail.PreviewProps = {
  userName: 'John Doe',
  workspaceDisplayName: 'Acme Inc.',
  trialEndsAt: new Date('2026-07-02'),
  dataRetentionDays: 14,
  link: 'https://acme.twenty.com/settings/billing',
  locale: 'en',
} as BillingTrialEndingEmailProps;

export default BillingTrialEndingEmail;