Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add partner referral and status update notifications (#3394)

Marcus Farrellab6c15a80585
diff --git a/apps/web/lib/actions/referrals/mark-referral-closed-lost.ts b/apps/web/lib/actions/referrals/mark-referral-closed-lost.ts
index e0e3f287b9..975ffa8a17 100644
--- a/apps/web/lib/actions/referrals/mark-referral-closed-lost.ts
+++ b/apps/web/lib/actions/referrals/mark-referral-closed-lost.ts
@@ -3,9 +3,11 @@
import { DubApiError } from "@/lib/api/errors";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { getReferralOrThrow } from "@/lib/api/referrals/get-referral-or-throw";
+import { notifyReferralStatusUpdate } from "@/lib/api/referrals/notify-referral-status-update";
import { markReferralClosedLostSchema } from "@/lib/zod/schemas/referrals";
import { prisma } from "@dub/prisma";
import { ReferralStatus } from "@dub/prisma/client";
+import { waitUntil } from "@vercel/functions";
import { authActionClient } from "../safe-action";
// Mark a partner referral as closed lost
@@ -13,7 +15,7 @@ export const markReferralClosedLostAction = authActionClient
.inputSchema(markReferralClosedLostSchema)
.action(async ({ parsedInput, ctx }) => {
const { workspace } = ctx;
- const { referralId } = parsedInput;
+ const { referralId, notes } = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -37,4 +39,13 @@ export const markReferralClosedLostAction = authActionClient
status: ReferralStatus.closedLost,
},
});
+
+ waitUntil(
+ notifyReferralStatusUpdate({
+ referral: partnerReferral,
+ programId,
+ status: ReferralStatus.closedLost,
+ notes,
+ }),
+ );
});
diff --git a/apps/web/lib/actions/referrals/mark-referral-closed-won.ts b/apps/web/lib/actions/referrals/mark-referral-closed-won.ts
index 83d2d6db72..b811b99da3 100644
--- a/apps/web/lib/actions/referrals/mark-referral-closed-won.ts
+++ b/apps/web/lib/actions/referrals/mark-referral-closed-won.ts
@@ -4,6 +4,7 @@ import { trackSale } from "@/lib/api/conversions/track-sale";
import { DubApiError } from "@/lib/api/errors";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { getReferralOrThrow } from "@/lib/api/referrals/get-referral-or-throw";
+import { notifyReferralStatusUpdate } from "@/lib/api/referrals/notify-referral-status-update";
import { markReferralClosedWonSchema } from "@/lib/zod/schemas/referrals";
import { prisma } from "@dub/prisma";
import { ReferralStatus } from "@dub/prisma/client";
@@ -15,7 +16,7 @@ export const markReferralClosedWonAction = authActionClient
.inputSchema(markReferralClosedWonSchema)
.action(async ({ parsedInput, ctx }) => {
const { workspace } = ctx;
- const { referralId, saleAmount, stripeCustomerId } = parsedInput;
+ const { referralId, saleAmount, stripeCustomerId, notes } = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -63,13 +64,22 @@ export const markReferralClosedWonAction = authActionClient
// Update customer with the stripe customer ID
waitUntil(
- prisma.customer.update({
- where: {
- id: referral.customerId!,
- },
- data: {
- stripeCustomerId,
- },
- }),
+ (async () => {
+ await prisma.customer.update({
+ where: {
+ id: referral.customerId!,
+ },
+ data: {
+ stripeCustomerId,
+ },
+ });
+
+ await notifyReferralStatusUpdate({
+ referral,
+ programId,
+ status: ReferralStatus.closedWon,
+ notes,
+ });
+ })(),
);
});
diff --git a/apps/web/lib/actions/referrals/mark-referral-qualified.ts b/apps/web/lib/actions/referrals/mark-referral-qualified.ts
index b86f1d5e0c..69f274e5cf 100644
--- a/apps/web/lib/actions/referrals/mark-referral-qualified.ts
+++ b/apps/web/lib/actions/referrals/mark-referral-qualified.ts
@@ -5,6 +5,7 @@ import { createId } from "@/lib/api/create-id";
import { DubApiError } from "@/lib/api/errors";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { getReferralOrThrow } from "@/lib/api/referrals/get-referral-or-throw";
+import { notifyReferralStatusUpdate } from "@/lib/api/referrals/notify-referral-status-update";
import { recordFakeClick } from "@/lib/tinybird/record-fake-click";
import { markReferralQualifiedSchema } from "@/lib/zod/schemas/referrals";
import { prisma } from "@dub/prisma";
@@ -18,7 +19,7 @@ export const markReferralQualifiedAction = authActionClient
.inputSchema(markReferralQualifiedSchema)
.action(async ({ parsedInput, ctx }) => {
const { workspace } = ctx;
- const { referralId, externalId } = parsedInput;
+ const { referralId, externalId, notes } = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -117,6 +118,13 @@ export const markReferralQualifiedAction = authActionClient
customerId: customer.id,
},
});
+
+ await notifyReferralStatusUpdate({
+ referral,
+ programId,
+ status: ReferralStatus.qualified,
+ notes,
+ });
})(),
);
});
diff --git a/apps/web/lib/actions/referrals/mark-referral-unqualified.ts b/apps/web/lib/actions/referrals/mark-referral-unqualified.ts
index c932a851bf..174ed30ae8 100644
--- a/apps/web/lib/actions/referrals/mark-referral-unqualified.ts
+++ b/apps/web/lib/actions/referrals/mark-referral-unqualified.ts
@@ -3,9 +3,11 @@
import { DubApiError } from "@/lib/api/errors";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { getReferralOrThrow } from "@/lib/api/referrals/get-referral-or-throw";
+import { notifyReferralStatusUpdate } from "@/lib/api/referrals/notify-referral-status-update";
import { markReferralUnqualifiedSchema } from "@/lib/zod/schemas/referrals";
import { prisma } from "@dub/prisma";
import { ReferralStatus } from "@dub/prisma/client";
+import { waitUntil } from "@vercel/functions";
import { authActionClient } from "../safe-action";
// Mark a partner referral as unqualified
@@ -13,7 +15,7 @@ export const markReferralUnqualifiedAction = authActionClient
.inputSchema(markReferralUnqualifiedSchema)
.action(async ({ parsedInput, ctx }) => {
const { workspace } = ctx;
- const { referralId } = parsedInput;
+ const { referralId, notes } = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -37,4 +39,13 @@ export const markReferralUnqualifiedAction = authActionClient
status: ReferralStatus.unqualified,
},
});
+
+ waitUntil(
+ notifyReferralStatusUpdate({
+ referral: partnerReferral,
+ programId,
+ status: ReferralStatus.unqualified,
+ notes,
+ }),
+ );
});
diff --git a/apps/web/lib/actions/referrals/submit-referral.ts b/apps/web/lib/actions/referrals/submit-referral.ts
index c9270cc3c7..48e31f5eae 100644
--- a/apps/web/lib/actions/referrals/submit-referral.ts
+++ b/apps/web/lib/actions/referrals/submit-referral.ts
@@ -10,9 +10,11 @@ import {
referralRequiredFieldsSchema,
} from "@/lib/zod/schemas/referral-form";
import { createPartnerReferralSchema } from "@/lib/zod/schemas/referrals";
+import { notifyPartnerReferralSubmitted } from "@/lib/api/referrals/notify-partner-referral-submitted";
import { prisma } from "@dub/prisma";
import { Prisma } from "@dub/prisma/client";
import { COUNTRIES } from "@dub/utils";
+import { waitUntil } from "@vercel/functions";
import * as z from "zod/v4";
import { authPartnerActionClient } from "../safe-action";
@@ -110,10 +112,13 @@ export const submitReferralAction = authPartnerActionClient
continue;
}
- // Skip undefined/null/empty string values (but allow 0 and false)
+ // Skip undefined/null/empty string/NaN so null values are never recorded (allow 0 and false)
if (value === undefined || value === null || value === "") {
continue;
}
+ if (typeof value === "number" && Number.isNaN(value)) {
+ continue;
+ }
// Get field schema to extract label and handle value conversion
const fieldSchema = fieldMap.get(key);
@@ -126,7 +131,7 @@ export const submitReferralAction = authPartnerActionClient
});
}
- await prisma.partnerReferral.create({
+ const referral = await prisma.partnerReferral.create({
data: {
id: createId({ prefix: "ref_" }),
programId,
@@ -140,4 +145,11 @@ export const submitReferralAction = authPartnerActionClient
: undefined,
},
});
+
+ waitUntil(
+ notifyPartnerReferralSubmitted({
+ referral,
+ programId,
+ }),
+ );
});
diff --git a/apps/web/lib/api/referrals/notify-partner-referral-submitted.ts b/apps/web/lib/api/referrals/notify-partner-referral-submitted.ts
new file mode 100644
index 0000000000..ba63d2f173
--- /dev/null
+++ b/apps/web/lib/api/referrals/notify-partner-referral-submitted.ts
@@ -0,0 +1,80 @@
+import { getCompanyLogoUrl } from "@/ui/referrals/referral-utils";
+import { sendBatchEmail } from "@dub/email";
+import PartnerReferralSubmitted from "@dub/email/templates/partner-referral-submitted";
+import { prisma } from "@dub/prisma";
+import { PartnerReferral } from "@dub/prisma/client";
+
+export async function notifyPartnerReferralSubmitted({
+ referral,
+ programId,
+}: {
+ referral: Pick<
+ PartnerReferral,
+ "id" | "name" | "email" | "company" | "formData"
+ >;
+ programId: string;
+}) {
+ const program = await prisma.program.findUnique({
+ where: { id: programId },
+ select: { workspaceId: true },
+ });
+
+ if (!program) return;
+
+ const workspaceUsers = await prisma.projectUsers.findMany({
+ where: {
+ projectId: program.workspaceId,
+ user: {
+ email: {
+ not: null,
+ },
+ isMachine: false,
+ },
+ },
+ include: {
+ user: {
+ select: {
+ email: true,
+ },
+ },
+ project: {
+ select: {
+ slug: true,
+ },
+ },
+ },
+ take: 100,
+ orderBy: {
+ createdAt: "asc",
+ },
+ });
+
+ // Parse formData from JSON
+ const formData = referral.formData as
+ | { label: string; value: unknown }[]
+ | null;
+
+ const emailsRes = await sendBatchEmail(
+ workspaceUsers.map(({ user, project }) => ({
+ subject: "New partner referral submitted",
+ variant: "notifications",
+ to: user.email!,
+ react: PartnerReferralSubmitted({
+ email: user.email!,
+ workspace: {
+ slug: project.slug,
+ },
+ referral: {
+ id: referral.id,
+ name: referral.name,
+ email: referral.email,
+ company: referral.company,
+ image: getCompanyLogoUrl(referral.email),
+ formData,
+ },
+ }),
+ })),
+ );
+
+ console.log(`Resend email sent: ${JSON.stringify(emailsRes, null, 2)}`);
+}
diff --git a/apps/web/lib/api/referrals/notify-referral-status-update.ts b/apps/web/lib/api/referrals/notify-referral-status-update.ts
new file mode 100644
index 0000000000..8f5c5e215d
--- /dev/null
+++ b/apps/web/lib/api/referrals/notify-referral-status-update.ts
@@ -0,0 +1,63 @@
+import { ReferralStatusBadges } from "@/ui/referrals/referral-status-badges";
+import { getCompanyLogoUrl } from "@/ui/referrals/referral-utils";
+import { sendEmail } from "@dub/email";
+import ReferralStatusUpdate from "@dub/email/templates/referral-status-update";
+import { prisma } from "@dub/prisma";
+import { PartnerReferral, ReferralStatus } from "@dub/prisma/client";
+
+export async function notifyReferralStatusUpdate({
+ referral,
+ programId,
+ status,
+ notes,
+}: {
+ referral: Pick<PartnerReferral, "name" | "email" | "company" | "partnerId">;
+ programId: string;
+ status: ReferralStatus;
+ notes?: string | null;
+}) {
+ const [program, partner] = await Promise.all([
+ prisma.program.findUnique({
+ where: { id: programId },
+ select: { name: true, slug: true },
+ }),
+
+ prisma.partner.findUnique({
+ where: { id: referral.partnerId },
+ select: {
+ name: true,
+ email: true,
+ },
+ }),
+ ]);
+
+ if (!program || !partner) return;
+
+ const statusLabel = ReferralStatusBadges[status].label;
+
+ const emailRes = await sendEmail({
+ subject: `Your referral status has been updated to ${statusLabel}`,
+ variant: "notifications",
+ to: partner.email!,
+ react: ReferralStatusUpdate({
+ partner: {
+ name: partner.name,
+ email: partner.email!,
+ },
+ program: {
+ name: program.name,
+ slug: program.slug,
+ },
+ referral: {
+ name: referral.name,
+ email: referral.email,
+ company: referral.company,
+ image: getCompanyLogoUrl(referral.email),
+ },
+ status: statusLabel,
+ notes,
+ }),
+ });
+
+ console.log(`Resend email sent: ${JSON.stringify(emailRes, null, 2)}`);
+}
diff --git a/apps/web/lib/zod/schemas/referrals.ts b/apps/web/lib/zod/schemas/referrals.ts
index f44e0ba651..3e3263d13f 100644
--- a/apps/web/lib/zod/schemas/referrals.ts
+++ b/apps/web/lib/zod/schemas/referrals.ts
@@ -66,11 +66,13 @@ export const markReferralQualifiedSchema = z.object({
referralId: z.string(),
workspaceId: z.string(),
externalId: z.string().trim().optional(),
+ notes: z.string().trim().optional(),
});
export const markReferralUnqualifiedSchema = z.object({
referralId: z.string(),
workspaceId: z.string(),
+ notes: z.string().trim().optional(),
});
export const markReferralClosedWonSchema = z.object({
@@ -80,9 +82,11 @@ export const markReferralClosedWonSchema = z.object({
.number()
.min(0, "Sale amount must be greater than or equal to 0"),
stripeCustomerId: z.string().optional(),
+ notes: z.string().trim().optional(),
});
export const markReferralClosedLostSchema = z.object({
referralId: z.string(),
workspaceId: z.string(),
+ notes: z.string().trim().optional(),
});
diff --git a/apps/web/ui/modals/mark-referral-closed-won-modal.tsx b/apps/web/ui/modals/mark-referral-closed-won-modal.tsx
index b8d75c40f6..adbac8fd03 100644
--- a/apps/web/ui/modals/mark-referral-closed-won-modal.tsx
+++ b/apps/web/ui/modals/mark-referral-closed-won-modal.tsx
@@ -121,15 +121,15 @@ function ReferralClosedWonModal({
</span>
</div>
- {errors.saleAmount && (
+ {errors.saleAmount ? (
<p className="text-xs text-red-600">
{errors.saleAmount.message}
</p>
+ ) : (
+ <p className="text-xs text-neutral-500">
+ This will also be recorded as a sale commission (if applicable)
+ </p>
)}
-
- <p className="text-xs text-neutral-500">
- This will be also recorded as a sale commission (if applicable)
- </p>
</div>
<div className="flex flex-col gap-2">
diff --git a/apps/web/ui/referrals/referral-details.tsx b/apps/web/ui/referrals/referral-details.tsx
index 19e172c3d6..c42600c912 100644
--- a/apps/web/ui/referrals/referral-details.tsx
+++ b/apps/web/ui/referrals/referral-details.tsx
@@ -11,6 +11,14 @@ export function ReferralDetails({ referral }: ReferralDetailsProps) {
| null
| undefined;
+ // Don't show fields with null/undefined/empty/NaN values (avoid displaying "null")
+ const displayFormData = formData?.filter((field) => {
+ const v = field.value;
+ if (v === undefined || v === null || v === "") return false;
+ if (typeof v === "number" && Number.isNaN(v)) return false;
+ return true;
+ });
+
return (
<div className="@3xl/sheet:order-1">
<div className="border-border-subtle overflow-hidden rounded-xl border bg-white p-4">
@@ -18,7 +26,7 @@ export function ReferralDetails({ referral }: ReferralDetailsProps) {
Referral details
</h3>
<div className="grid grid-cols-1 gap-4 text-sm text-neutral-600">
- {formData?.map((field) => (
+ {displayFormData?.map((field) => (
<div key={field.key}>
<div className="text-content-default text-sm font-semibold">
{field.label}
diff --git a/apps/web/ui/referrals/referral-utils.ts b/apps/web/ui/referrals/referral-utils.ts
index af1f1b6447..1c8c51579a 100644
--- a/apps/web/ui/referrals/referral-utils.ts
+++ b/apps/web/ui/referrals/referral-utils.ts
@@ -1,10 +1,13 @@
-import { GOOGLE_FAVICON_URL } from "@dub/utils";
+import { GOOGLE_FAVICON_URL, OG_AVATAR_URL } from "@dub/utils";
// Formats a formData field value for display
export function formatFormDataValue(value: unknown): string {
if (value === null || value === undefined || value === "") {
return "";
}
+ if (typeof value === "number" && Number.isNaN(value)) {
+ return "";
+ }
if (Array.isArray(value)) {
return value.map((v) => String(v)).join(", ");
@@ -26,7 +29,9 @@ export function formatFormDataValue(value: unknown): string {
}
// Gets company logo URL from email domain
-export function getCompanyLogoUrl(email: string): string | null {
+export function getCompanyLogoUrl(email: string) {
const emailDomain = email.split("@")[1];
- return emailDomain ? `${GOOGLE_FAVICON_URL}${emailDomain}` : null;
+ return emailDomain
+ ? `${GOOGLE_FAVICON_URL}${emailDomain}`
+ : `${OG_AVATAR_URL}${email}`;
}
diff --git a/apps/web/ui/referrals/submit-referral-sheet.tsx b/apps/web/ui/referrals/submit-referral-sheet.tsx
index f67ddcdea7..cca8d6b7cc 100644
--- a/apps/web/ui/referrals/submit-referral-sheet.tsx
+++ b/apps/web/ui/referrals/submit-referral-sheet.tsx
@@ -78,9 +78,22 @@ export function SubmitReferralSheet({
return;
}
+ // Strip null, undefined, empty string, and NaN so they are never recorded
+ const sanitizedFormData = Object.fromEntries(
+ Object.entries(data.formData).filter(([, value]) => {
+ if (value === undefined || value === null || value === "") {
+ return false;
+ }
+ if (typeof value === "number" && Number.isNaN(value)) {
+ return false;
+ }
+ return true;
+ }),
+ );
+
await executeAsync({
programId,
- formData: data.formData,
+ formData: sanitizedFormData,
});
};
diff --git a/packages/email/src/templates/partner-referral-submitted.tsx b/packages/email/src/templates/partner-referral-submitted.tsx
new file mode 100644
index 0000000000..652e390ad1
--- /dev/null
+++ b/packages/email/src/templates/partner-referral-submitted.tsx
@@ -0,0 +1,203 @@
+import { DUB_WORDMARK, OG_AVATAR_URL } 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 PartnerReferralSubmitted({
+ email = "[email protected]",
+ workspace = {
+ slug: "acme",
+ },
+ referral = {
+ id: "ref_1234567890",
+ name: "Jane Smith",
+ email: "[email protected]",
+ company: "Acme Corp",
+ image: null,
+ formData: [
+ {
+ label: "How did you meet this referral?",
+ value: "Met at a conference last month.",
+ },
+ {
+ label: "Expected deal size",
+ value: "$50,000",
+ },
+ ],
+ },
+}: {
+ email: string;
+ workspace: { slug: string };
+ referral: {
+ id: string;
+ name: string;
+ email: string;
+ company: string;
+ image: string | null;
+ formData?: { label: string; value: unknown }[] | null;
+ };
+}) {
+ const referralUrl = `https://app.dub.co/${workspace.slug}/program/customers/referrals?referralId=${referral.id}`;
+
+ return (
+ <Html>
+ <Head />
+ <Preview>
+ New partner referral from {referral.name} ({referral.email}) at{" "}
+ {referral.company}.
+ </Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[600px] rounded border border-solid border-neutral-200 px-10 py-5">
+ <Section className="mb-8 mt-6">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="dub" />
+ </Section>
+
+ <Heading className="mx-0 p-0 text-lg font-medium text-neutral-800">
+ New partner referral
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ You have a new partner referral to review, view the{" "}
+ <Link
+ href={referralUrl}
+ className="text-neutral-600 underline underline-offset-4"
+ >
+ full details on Dub
+ </Link>
+ .
+ </Text>
+
+ <Container className="mt-10 rounded-lg border border-solid border-neutral-200">
+ <Section className="p-2">
+ <Container className="w-full rounded-lg border border-solid border-neutral-100 bg-neutral-50 p-6">
+ <div>
+ <Img
+ src={
+ referral.image || `${OG_AVATAR_URL}${referral.email}`
+ }
+ width="48"
+ height="48"
+ alt={referral.name}
+ className="rounded-full"
+ />
+
+ <div>
+ <Text className="m-0 mt-3 p-0 text-lg font-medium text-neutral-900">
+ {referral.name}
+ </Text>
+ <table
+ cellPadding="0"
+ cellSpacing="0"
+ style={{ marginTop: "4px" }}
+ >
+ <tr>
+ <td
+ style={{
+ verticalAlign: "middle",
+ paddingRight: "6px",
+ lineHeight: 0,
+ }}
+ >
+ <Img
+ src="https://assets.dub.co/email-assets/icons/envelope.png"
+ width="14"
+ height="14"
+ className="opacity-75"
+ alt="envelope"
+ />
+ </td>
+ <td
+ style={{
+ verticalAlign: "middle",
+ fontSize: "14px",
+ color: "#737373",
+ }}
+ >
+ {referral.email}
+ </td>
+ </tr>
+ </table>
+ <table
+ cellPadding="0"
+ cellSpacing="0"
+ style={{ marginTop: "4px" }}
+ >
+ <tr>
+ <td
+ style={{
+ verticalAlign: "middle",
+ paddingRight: "6px",
+ lineHeight: 0,
+ }}
+ >
+ <Img
+ src="https://assets.dub.co/email-assets/icons/office-building.png"
+ width="14"
+ height="14"
+ className="opacity-75"
+ alt="office building"
+ />
+ </td>
+ <td
+ style={{
+ verticalAlign: "middle",
+ fontSize: "14px",
+ color: "#737373",
+ }}
+ >
+ {referral.company}
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </Container>
+
+ {referral.formData && referral.formData.length > 0 && (
+ <Section className="px-4 pt-4">
+ {referral.formData.map((field) => (
+ <Section key={field.label} className="mb-4">
+ <Text className="m-0 mb-2 p-0 text-base font-medium text-neutral-900">
+ {field.label}
+ </Text>
+ <Text className="m-0 p-0 leading-6 text-neutral-600">
+ {String(field.value)}
+ </Text>
+ </Section>
+ ))}
+ </Section>
+ )}
+ </Section>
+ </Container>
+
+ <Section className="mb-8 mt-8 text-center">
+ <Link
+ href={referralUrl}
+ className="box-border block w-full rounded-lg bg-black px-0 py-4 text-center text-sm font-semibold leading-none text-white no-underline"
+ >
+ Review on Dub
+ </Link>
+ </Section>
+
+ <Footer
+ email={email}
+ notificationSettingsUrl={`https://app.dub.co/${workspace.slug}/settings/notifications`}
+ />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/referral-status-update.tsx b/packages/email/src/templates/referral-status-update.tsx
new file mode 100644
index 0000000000..e17b0ac047
--- /dev/null
+++ b/packages/email/src/templates/referral-status-update.tsx
@@ -0,0 +1,175 @@
+import { DUB_WORDMARK, OG_AVATAR_URL } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function ReferralStatusUpdate({
+ partner = {
+ name: "John Doe",
+ email: "[email protected]",
+ },
+ program = {
+ name: "Acme",
+ slug: "acme",
+ },
+ referral = {
+ name: "Jane Smith",
+ email: "[email protected]",
+ company: "Acme Corp",
+ image: null,
+ },
+ status = "Qualified",
+ notes,
+}: {
+ partner: { name: string; email: string };
+ program: { name: string; slug: string };
+ referral: {
+ name: string;
+ email: string;
+ company: string;
+ image: string | null;
+ };
+ status: string;
+ notes?: string | null;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>
+ Your referral {referral.name} has been updated to {status}.
+ </Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[600px] rounded border border-solid border-neutral-200 px-10 py-5">
+ <Section className="mb-8 mt-6">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="dub" />
+ </Section>
+
+ <Heading className="mx-0 p-0 text-lg font-medium text-neutral-800">
+ Referral status update
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Your submitted referral has changed to <strong>{status}</strong>{" "}
+ by <strong>{program.name}</strong>.
+ </Text>
+
+ {notes && (
+ <>
+ <Text className="mb-0 text-sm font-semibold leading-6 text-neutral-800">
+ Additional notes from {program.name}:
+ </Text>
+ <Text className="mt-1 text-sm leading-6 text-neutral-600">
+ {notes}
+ </Text>
+ </>
+ )}
+
+ <Container className="mb-8 mt-10 rounded-lg border border-solid border-neutral-200">
+ <Section className="p-2">
+ <Container className="w-full rounded-lg border border-solid border-neutral-100 bg-neutral-50 p-6">
+ <div>
+ <Img
+ src={
+ referral.image || `${OG_AVATAR_URL}${referral.email}`
+ }
+ width="48"
+ height="48"
+ alt={referral.name}
+ className="rounded-full"
+ />
+
+ <div>
+ <Text className="m-0 mt-3 p-0 text-lg font-medium text-neutral-900">
+ {referral.name}
+ </Text>
+ <table
+ cellPadding="0"
+ cellSpacing="0"
+ style={{ marginTop: "4px" }}
+ >
+ <tr>
+ <td
+ style={{
+ verticalAlign: "middle",
+ paddingRight: "6px",
+ lineHeight: 0,
+ }}
+ >
+ <Img
+ src="https://assets.dub.co/email-assets/icons/envelope.png"
+ width="14"
+ height="14"
+ className="opacity-75"
+ alt="envelope"
+ />
+ </td>
+ <td
+ style={{
+ verticalAlign: "middle",
+ fontSize: "14px",
+ color: "#737373",
+ }}
+ >
+ {referral.email}
+ </td>
+ </tr>
+ </table>
+ <table
+ cellPadding="0"
+ cellSpacing="0"
+ style={{ marginTop: "4px" }}
+ >
+ <tr>
+ <td
+ style={{
+ verticalAlign: "middle",
+ paddingRight: "6px",
+ lineHeight: 0,
+ }}
+ >
+ <Img
+ src="https://assets.dub.co/email-assets/icons/office-building.png"
+ width="14"
+ height="14"
+ alt="office building"
+ className="opacity-75"
+ />
+ </td>
+ <td
+ style={{
+ verticalAlign: "middle",
+ fontSize: "14px",
+ color: "#737373",
+ }}
+ >
+ {referral.company}
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </Container>
+ </Section>
+ </Container>
+
+ <Footer
+ email={partner.email}
+ notificationSettingsUrl="https://partners.dub.co/settings/notifications"
+ />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}