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 notification email

Steven Tey56e5fdb782de
diff --git a/apps/web/lib/actions/partners/deactivate-partner.ts b/apps/web/lib/actions/partners/deactivate-partner.ts
index 4d142a9426..5d5e4deb80 100644
--- a/apps/web/lib/actions/partners/deactivate-partner.ts
+++ b/apps/web/lib/actions/partners/deactivate-partner.ts
@@ -6,6 +6,8 @@ import { linkCache } from "@/lib/api/links/cache";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw";
import { deactivatePartnerSchema } from "@/lib/zod/schemas/partners";
+import { sendEmail } from "@dub/email";
+import PartnerDeactivated from "@dub/email/templates/partner-deactivated";
import { prisma } from "@dub/prisma";
import { ProgramEnrollmentStatus } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
@@ -24,6 +26,7 @@ export const deactivatePartnerAction = authActionClient
partnerId,
programId,
include: {
+ program: true,
partner: true,
links: true,
discountCodes: true,
@@ -59,10 +62,26 @@ export const deactivatePartnerAction = authActionClient
waitUntil(
(async () => {
- const { links, discountCodes } = programEnrollment;
+ const { program, partner, links, discountCodes } = programEnrollment;
await Promise.allSettled([
- // TODO send email to partner
+ partner.email &&
+ sendEmail({
+ subject: `Your partnership with ${program.name} has been deactivated`,
+ to: partner.email,
+ replyTo: program.supportEmail || "noreply",
+ react: PartnerDeactivated({
+ partner: {
+ name: partner.name,
+ email: partner.email,
+ },
+ program: {
+ name: program.name,
+ slug: program.slug,
+ },
+ }),
+ variant: "notifications",
+ }),
linkCache.expireMany(links),
queueDiscountCodeDeletion(discountCodes.map(({ id }) => id)),
recordAuditLog({
diff --git a/apps/web/lib/email/email-templates-map.ts b/apps/web/lib/email/email-templates-map.ts
index 281243cd80..ecdc1ac7e1 100644
--- a/apps/web/lib/email/email-templates-map.ts
+++ b/apps/web/lib/email/email-templates-map.ts
@@ -1,7 +1,9 @@
+import PartnerDeactivated from "@dub/email/templates/partner-deactivated";
import PartnerPayoutConfirmed from "@dub/email/templates/partner-payout-confirmed";
import PartnerPayoutProcessed from "@dub/email/templates/partner-payout-processed";
export const EMAIL_TEMPLATES_MAP = {
PartnerPayoutConfirmed,
PartnerPayoutProcessed,
+ PartnerDeactivated,
} as const;
diff --git a/packages/email/src/templates/partner-banned.tsx b/packages/email/src/templates/partner-banned.tsx
index 53399b395d..5f3011fbeb 100644
--- a/packages/email/src/templates/partner-banned.tsx
+++ b/packages/email/src/templates/partner-banned.tsx
@@ -65,7 +65,7 @@ export default function PartnerBanned({
</Text>
<Text className="text-sm leading-6 text-neutral-600">
- If you wish to appeal this ban, please{" "}
+ If you have any questions, please{" "}
<Link
href={`https://partners.dub.co/messages/${program.slug}`}
className="font-semibold text-neutral-700 underline underline-offset-2"
diff --git a/packages/email/src/templates/partner-deactivated.tsx b/packages/email/src/templates/partner-deactivated.tsx
new file mode 100644
index 0000000000..49832cc8f5
--- /dev/null
+++ b/packages/email/src/templates/partner-deactivated.tsx
@@ -0,0 +1,84 @@
+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 PartnerDeactivated({
+ partner = {
+ name: "John",
+ email: "[email protected]",
+ },
+ program = {
+ name: "Perplexity",
+ slug: "acme",
+ },
+ deactivatedReason,
+}: {
+ partner: {
+ name: string;
+ email: string;
+ };
+ program: {
+ name: string;
+ slug: string;
+ };
+ deactivatedReason?: string;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>
+ {program.name} has deactivated your partnership with their program.
+ </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-600">
+ Your partnership with {program.name} has been deactivated
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Hello {partner.name}! {program.name} has deactivated your
+ partnership with their program
+ {deactivatedReason ? ` ${deactivatedReason}` : ""}.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ All your links have been disabled, but your pending commissions
+ and payouts will remain until they are approved and paid out by
+ the {program.name} team.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ If you have any questions, please{" "}
+ <Link
+ href={`https://partners.dub.co/messages/${program.slug}`}
+ className="font-semibold text-neutral-700 underline underline-offset-2"
+ >
+ reach out to the {program.name} team ↗
+ </Link>
+ .
+ </Text>
+
+ <Footer email={partner.email} />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}