The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add email templates for submitted lead comments
Rafid4b5e5e4c723
diff --git a/packages/email/src/components/submitted-lead-comments-card.tsx b/packages/email/src/components/submitted-lead-comments-card.tsxnew file mode 100644index 0000000000..74c9a94377--- /dev/null+++ b/packages/email/src/components/submitted-lead-comments-card.tsx@@ -0,0 +1,118 @@+import { OG_AVATAR_URL } from "@dub/utils";+import {+ Column,+ Img,+ Link,+ Markdown,+ Row,+ Section,+ Text,+} from "@react-email/components";++const MAX_DISPLAYED_COMMENTS = 3;++export type SubmittedLeadCommentEmailProps = {+ text: string;+ createdAt: Date;+ user: {+ name: string;+ image: string | null;+ };+};++export function SubmittedLeadCommentsCard({+ lead,+ comments,+ buttonText,+ buttonUrl,+}: {+ lead: {+ name: string;+ email: string;+ image: string | null;+ };+ comments: SubmittedLeadCommentEmailProps[];+ buttonText: string;+ buttonUrl: string;+}) {+ return (+ <Section className="rounded-xl border border-solid border-neutral-200">+ <Row className="px-4 py-4">+ <Column className="w-[36px] align-middle">+ <Img+ src={lead.image || `${OG_AVATAR_URL}${lead.email}`}+ width="32"+ height="32"+ alt={lead.name}+ className="rounded-full"+ />+ </Column>+ <Column className="pl-3 align-middle">+ <Text className="my-0 text-[15px] font-semibold text-neutral-800">+ {lead.name}+ </Text>+ <Text className="my-0 text-[13px] text-neutral-500">+ {lead.email}+ </Text>+ </Column>+ </Row>++ <Section className="rounded-b-xl border-0 border-t border-solid border-neutral-200 bg-neutral-50 px-3 pb-3">+ {comments.slice(0, MAX_DISPLAYED_COMMENTS).map((comment, idx) => (+ <Section+ key={idx}+ className="mt-3 rounded-lg border border-solid border-neutral-200 bg-white px-4"+ >+ <Text className="mb-0 mt-3 text-[12px] text-neutral-500">+ <Img+ src={+ comment.user.image || `${OG_AVATAR_URL}${comment.user.name}`+ }+ width="16"+ height="16"+ alt={comment.user.name}+ className="mr-1.5 inline-block rounded-full align-middle"+ />+ <span className="align-middle font-semibold text-neutral-800">+ {comment.user.name}+ </span>+ <span className="align-middle">+ · + {comment.createdAt.toLocaleTimeString("en-US", {+ hour: "numeric",+ minute: "numeric",+ })}+ </span>+ </Text>+ <Markdown+ markdownCustomStyles={{+ link: { color: "#262626", textDecoration: "underline" },+ }}+ markdownContainerStyles={{+ fontSize: 14,+ lineHeight: "20px",+ color: "#262626",+ }}+ >+ {comment.text}+ </Markdown>+ </Section>+ ))}+ {comments.length > MAX_DISPLAYED_COMMENTS && (+ <Text className="mb-0 mt-3 text-center text-[12px] text-neutral-500">+ {comments.length - MAX_DISPLAYED_COMMENTS} more{" "}+ {comments.length - MAX_DISPLAYED_COMMENTS === 1+ ? "comment"+ : "comments"}+ </Text>+ )}+ <Link+ className="mt-3 block rounded-lg bg-neutral-900 px-6 py-3 text-center text-[13px] font-medium text-white no-underline"+ href={buttonUrl}+ >+ {buttonText}+ </Link>+ </Section>+ </Section>+ );+}diff --git a/packages/email/src/templates/new-submitted-lead-comments-from-partner.tsx b/packages/email/src/templates/new-submitted-lead-comments-from-partner.tsxnew file mode 100644index 0000000000..dfa4ea1fdc--- /dev/null+++ b/packages/email/src/templates/new-submitted-lead-comments-from-partner.tsx@@ -0,0 +1,99 @@+import { DUB_WORDMARK } from "@dub/utils";+import {+ Body,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Section,+ Tailwind,+} from "@react-email/components";+import { Footer } from "../components/footer";+import {+ SubmittedLeadCommentEmailProps,+ SubmittedLeadCommentsCard,+} from "../components/submitted-lead-comments-card";++export default function NewSubmittedLeadCommentsFromPartner({+ workspace = {+ slug: "acme",+ },+ partner = {+ id: "pn_123",+ name: "Derek Forbes",+ },+ lead = {+ id: "sbl_123",+ name: "Jim Stephenson",+ email: "[email protected]",+ image: null,+ },+ comments = [+ {+ text: "Here's a link to their [contact info](https://dub.co).",+ createdAt: new Date(),+ user: { name: "Derek Forbes", image: null },+ },+ ],+ email = "[email protected]",+}: {+ workspace: {+ slug: string;+ };+ partner: {+ id: string;+ name: string;+ };+ lead: {+ id: string;+ name: string;+ email: string;+ image: string | null;+ };+ comments: SubmittedLeadCommentEmailProps[];+ email: string;+}) {+ const leadUrl = `https://app.dub.co/${workspace.slug}/program/leads?leadId=${lead.id}`;+ const partnerUrl = `https://app.dub.co/${workspace.slug}/program/partners/${partner.id}`;+ const title = `${comments.length} submitted lead ${comments.length === 1 ? "comment" : "comments"} from ${partner.name}`;++ return (+ <Html>+ <Head />+ <Preview>{title}</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-8 max-w-[600px] px-8 py-8">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Section className="my-8">+ <Heading className="my-0 text-lg font-semibold text-black">+ {title}+ </Heading>+ <Link+ className="text-[13px] font-medium text-neutral-500 underline"+ href={partnerUrl}+ >+ View profile in Dub+ </Link>+ </Section>++ <SubmittedLeadCommentsCard+ lead={lead}+ comments={comments}+ buttonText="View in Dub"+ buttonUrl={leadUrl}+ />++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}diff --git a/packages/email/src/templates/new-submitted-lead-comments-from-program.tsx b/packages/email/src/templates/new-submitted-lead-comments-from-program.tsxnew file mode 100644index 0000000000..dc59be51f1--- /dev/null+++ b/packages/email/src/templates/new-submitted-lead-comments-from-program.tsx@@ -0,0 +1,112 @@+import { DUB_WORDMARK } from "@dub/utils";+import {+ Body,+ Column,+ Container,+ Head,+ Heading,+ Html,+ Img,+ Link,+ Preview,+ Row,+ Section,+ Tailwind,+} from "@react-email/components";+import { Footer } from "../components/footer";+import {+ SubmittedLeadCommentEmailProps,+ SubmittedLeadCommentsCard,+} from "../components/submitted-lead-comments-card";++export default function NewSubmittedLeadCommentsFromProgram({+ program = {+ name: "Acme",+ slug: "acme",+ logo: "https://assets.dub.co/misc/acme-logo.png",+ },+ lead = {+ id: "sbl_123",+ name: "Jim Stephenson",+ email: "[email protected]",+ image: null,+ },+ comments = [+ {+ text: "Please?",+ createdAt: new Date(Date.now() - 1000 * 60 * 2),+ user: { name: "Steven Tey", image: null },+ },+ {+ text: "Can you please provide a PDF of their contact info?",+ createdAt: new Date(),+ user: { name: "Steven Tey", image: null },+ },+ ],+ email = "[email protected]",+}: {+ program: {+ name: string;+ slug: string;+ logo: string | null;+ };+ lead: {+ id: string;+ name: string;+ email: string;+ image: string | null;+ };+ comments: SubmittedLeadCommentEmailProps[];+ email: string;+}) {+ const leadUrl = `https://partners.dub.co/programs/${program.slug}/leads?leadId=${lead.id}`;+ const title = `${program.name} sent ${comments.length === 1 ? "a comment" : `${comments.length} comments`} for your submitted lead`;++ return (+ <Html>+ <Head />+ <Preview>{title}</Preview>+ <Tailwind>+ <Body className="mx-auto my-auto bg-white font-sans">+ <Container className="mx-auto my-8 max-w-[600px] px-8 py-8">+ <Section className="mt-8">+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />+ </Section>++ <Row className="my-8">+ <Column className="w-[40px] align-middle">+ <Img+ src={program.logo || "https://assets.dub.co/wordmark.png"}+ width="32"+ height="32"+ alt={program.name}+ className="rounded-full"+ />+ </Column>+ <Column className="pl-2 align-middle">+ <Heading className="my-0 text-lg font-semibold text-black">+ {title}+ </Heading>+ <Link+ className="text-[13px] font-medium text-neutral-500 underline"+ href={leadUrl}+ >+ View submitted lead in Dub+ </Link>+ </Column>+ </Row>++ <SubmittedLeadCommentsCard+ lead={lead}+ comments={comments}+ buttonText="Reply in Dub"+ buttonUrl={leadUrl}+ />++ <Footer email={email} />+ </Container>+ </Body>+ </Tailwind>+ </Html>+ );+}