The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add domain lifecycle email templates and update schema
Kiran K5a1ae597aaf3
diff --git a/packages/email/src/templates/domain-expired.tsx b/packages/email/src/templates/domain-expired.tsxnew file mode 100644index 0000000000..060bfc3b58--- /dev/null+++ b/packages/email/src/templates/domain-expired.tsx@@ -0,0 +1,82 @@+import { DUB_WORDMARK } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import { Footer } from "../components/footer";++export default function DomainExpired({+ email = "[email protected]",+ workspace = {+ name: "Acme, Inc",+ slug: "acme",+ },+ domain = {+ slug: "getacme.link",+ },+}: {+ email: string;+ workspace: {+ name: string;+ slug: string;+ };+ domain: {+ slug: string;+ };+}) {+ return (+ <Html>+ <Head />+ <Preview>Domain expiration</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-10 max-w-[600px] px-5 py-5">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Heading className="mx-0 mb-5 mt-10 p-0 text-lg font-semibold text-neutral-800">+ Domain expiration+ </Heading>++ <Text className="text-sm leading-6 text-neutral-600">+ The domain{" "}+ <Link+ href={domain.slug}+ className="font-semibold text-black underline"+ >+ {domain.slug}+ </Link>{" "}+ has expired and is no longer available to use with your workspace{" "}+ <span className="font-semibold text-black">{workspace.name}</span>+ .+ </Text>++ <Text className="text-sm leading-6 text-neutral-600">+ If you own the domain again in the future, you can add it to your+ workspace anytime in the{" "}+ <Link+ href={`https://app.dub.co/${workspace.slug}/links/domains`}+ className="font-semibold text-black underline"+ >+ domain settings page+ </Link>+ .+ </Text>++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/email/src/templates/domain-renewal-failed.tsx b/packages/email/src/templates/domain-renewal-failed.tsxnew file mode 100644index 0000000000..1c08adefad--- /dev/null+++ b/packages/email/src/templates/domain-renewal-failed.tsx@@ -0,0 +1,84 @@+import { DUB_WORDMARK, formatDate } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import { Footer } from "../components/footer";++export default function DomainRenewalFailed({+ email = "[email protected]",+ workspace = {+ slug: "acme",+ },+ domain = {+ slug: "getacme.link",+ expiresAt: new Date("2025-07-29"),+ },+}: {+ email: string;+ workspace: {+ slug: string;+ };+ domain: {+ slug: string;+ expiresAt: Date;+ };+}) {+ return (+ <Html>+ <Head />+ <Preview>Failed domain renewal payment</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-10 max-w-[600px] px-5 py-5">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Heading className="mx-0 mb-5 mt-10 p-0 text-lg font-semibold text-neutral-800">+ Failed domain renewal payment+ </Heading>++ <Text className="text-sm leading-6 text-neutral-600">+ We attempted to charge your card to renew the domain{" "}+ <Link+ href={domain.slug}+ className="font-semibold text-black underline"+ >+ {domain.slug}+ </Link>+ , which expires on{" "}+ <span className="font-semibold text-black">+ {formatDate(domain.expiresAt)}+ </span>+ , but it failed. We will try again in 3 days.+ </Text>++ <Text className="text-sm leading-6 text-neutral-600">+ If you don't want to renew your domain, turn off auto-renewal in+ your{" "}+ <Link+ href={`https://app.dub.co/${workspace.slug}/links/domains`}+ className="font-semibold text-black underline"+ >+ domain settings page+ </Link>+ .+ </Text>++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/email/src/templates/domain-renewal-reminder.tsx b/packages/email/src/templates/domain-renewal-reminder.tsxnew file mode 100644index 0000000000..2be45fc5fe--- /dev/null+++ b/packages/email/src/templates/domain-renewal-reminder.tsx@@ -0,0 +1,90 @@+import { currencyFormatter, DUB_WORDMARK, formatDate } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import { Footer } from "../components/footer";++export default function DomainRenewalReminder({+ email = "[email protected]",+ workspace = {+ slug: "acme",+ },+ domain = {+ slug: "getacme.link",+ expiresAt: new Date("2025-07-29"),+ renewalFee: 1200,+ nextChargeAt: new Date("2025-08-11"),+ },+}: {+ email: string;+ workspace: {+ slug: string;+ };+ domain: {+ slug: string;+ expiresAt: Date;+ renewalFee: number;+ nextChargeAt: Date;+ };+}) {+ return (+ <Html>+ <Head />+ <Preview>Domain renewal reminder</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-10 max-w-[600px] px-5 py-5">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Heading className="mx-0 mb-5 mt-10 p-0 text-lg font-semibold text-neutral-800">+ Domain renewal reminder+ </Heading>++ <Text className="text-sm leading-6 text-neutral-600">+ The domain{" "}+ <Link+ href={domain.slug}+ className="font-semibold text-black underline"+ >+ {domain.slug}+ </Link>{" "}+ will renew in 30 days on{" "}+ <span className="font-semibold text-black">+ {formatDate(domain.expiresAt)}+ </span>+ . We will attempt to charge your card on file{" "}+ {currencyFormatter(domain.renewalFee / 100)} in 2 weeks on{" "}+ {formatDate(domain.nextChargeAt)}.+ </Text>++ <Text className="text-sm leading-6 text-neutral-600">+ If you don't want to renew your domain, turn off auto-renewal in+ your{" "}+ <Link+ href={`https://app.dub.co/${workspace.slug}/links/domains`}+ className="font-semibold text-black underline"+ >+ domain settings page+ </Link>+ .+ </Text>++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/email/src/templates/domain-renewed.tsx b/packages/email/src/templates/domain-renewed.tsxnew file mode 100644index 0000000000..ad6b3db5d7--- /dev/null+++ b/packages/email/src/templates/domain-renewed.tsx@@ -0,0 +1,67 @@+import { DUB_WORDMARK, formatDate } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+ Text,+} from "@react-email/components";+import { Footer } from "../components/footer";++export default function DomainRenewed({+ email = "[email protected]",+ domain = {+ slug: "getacme.link",+ expiresAt: new Date("2026-07-29"),+ },+}: {+ email: string;+ domain: {+ slug: string;+ expiresAt: Date;+ };+}) {+ return (+ <Html>+ <Head />+ <Preview>Domain renewed</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-10 max-w-[600px] px-5 py-5">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Heading className="mx-0 mb-5 mt-10 p-0 text-lg font-semibold text-neutral-800">+ Domain renewed+ </Heading>++ <Text className="text-sm leading-6 text-neutral-600">+ The domain{" "}+ <Link+ href={domain.slug}+ className="font-semibold text-black underline"+ >+ {domain.slug}+ </Link>{" "}+ has been renewed for 1 year and has been processed. This+ registration expires on{" "}+ <span className="font-semibold text-black">+ {formatDate(domain.expiresAt)}+ </span>+ .+ </Text>++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/prisma/schema/domain.prisma b/packages/prisma/schema/domain.prismaindex 2f0dc2bd62..72697919b1 100644--- a/packages/prisma/schema/domain.prisma+++ b/packages/prisma/schema/domain.prisma@@ -30,19 +30,16 @@ model RegisteredDomain {slug StringprojectId StringdomainId String? @unique- invoiceId String?autoRenewalDisabledAt DateTime?renewalFee Int @default(1200) // $12expiresAt DateTimecreatedAt DateTime @default(now())updatedAt DateTime @updatedAt- project Project @relation(fields: [projectId], references: [id])- domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull)- invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: SetNull)+ project Project @relation(fields: [projectId], references: [id])+ domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull)@@index(projectId)- @@index(invoiceId)@@index(expiresAt(sort: Asc))}diff --git a/packages/prisma/schema/invoice.prisma b/packages/prisma/schema/invoice.prismaindex e3c0de3959..7fe32be52d 100644--- a/packages/prisma/schema/invoice.prisma+++ b/packages/prisma/schema/invoice.prisma@@ -21,15 +21,15 @@ model Invoice {total Int @default(0) // amount + fee in usd centsreceiptUrl String? @db.TextfailedReason String? @db.Text+ registeredDomains Json? @db.Json // Array of RegisteredDomainstripeChargeMetadata Json? @db.Json // Stripe charge metadatafailedAttempts Int @default(0) // number of failed attempts to charge the invoicecreatedAt DateTime @default(now())paidAt DateTime?- payouts Payout[]- registeredDomains RegisteredDomain[]- program Program @relation(fields: [programId], references: [id])- workspace Project @relation(fields: [workspaceId], references: [id])+ payouts Payout[]+ program Program @relation(fields: [programId], references: [id])+ workspace Project @relation(fields: [workspaceId], references: [id])@@index(programId)@@index(workspaceId)