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

Kiran K136660fcf6fd
diff --git a/apps/web/lib/actions/partners/merge-partner-accounts.ts b/apps/web/lib/actions/partners/merge-partner-accounts.ts
index a29d9a0d53..21e82e75da 100644
--- a/apps/web/lib/actions/partners/merge-partner-accounts.ts
+++ b/apps/web/lib/actions/partners/merge-partner-accounts.ts
@@ -8,6 +8,7 @@ import { redis } from "@/lib/upstash";
import { emailSchema } from "@/lib/zod/schemas/auth";
import { resend } from "@dub/email/resend";
import { VARIANT_TO_FROM_MAP } from "@dub/email/resend/constants";
+import PartnerAccountMerged from "@dub/email/templates/partner-account-merged";
import VerifyEmailForAccountMerge from "@dub/email/templates/verify-email-for-account-merge";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
@@ -146,34 +147,28 @@ const sendTokens = async ({
],
});
- if (!resend) {
- throw new Error("Resend is not configured.");
- }
-
- waitUntil(
- resend.batch.send([
- {
- from: VARIANT_TO_FROM_MAP.notifications,
- to: sourceEmail,
- subject: "Verify your email to merge your Dub Partners accounts",
- react: VerifyEmailForAccountMerge({
- email: sourceEmail,
- code: sourceEmailCode,
- expiresInMinutes: EMAIL_OTP_EXPIRY_IN / 60,
- }),
- },
- {
- from: VARIANT_TO_FROM_MAP.notifications,
- to: targetEmail,
- subject: "Connect your payout details on Dub Partners",
- react: VerifyEmailForAccountMerge({
- email: targetEmail,
- code: targetEmailCode,
- expiresInMinutes: EMAIL_OTP_EXPIRY_IN / 60,
- }),
- },
- ]),
- );
+ await resend?.batch.send([
+ {
+ from: VARIANT_TO_FROM_MAP.notifications,
+ to: sourceEmail,
+ subject: "Verify your email to merge your Dub Partners accounts",
+ react: VerifyEmailForAccountMerge({
+ email: sourceEmail,
+ code: sourceEmailCode,
+ expiresInMinutes: EMAIL_OTP_EXPIRY_IN / 60,
+ }),
+ },
+ {
+ from: VARIANT_TO_FROM_MAP.notifications,
+ to: targetEmail,
+ subject: "Connect your payout details on Dub Partners",
+ react: VerifyEmailForAccountMerge({
+ email: targetEmail,
+ code: targetEmailCode,
+ expiresInMinutes: EMAIL_OTP_EXPIRY_IN / 60,
+ }),
+ },
+ ]);
};
// Step 2: Verify email verification tokens
@@ -364,7 +359,6 @@ const mergeAccounts = async ({ userId }: { userId: string }) => {
// TODO:
// Remove the source partner from the database
- // Send email to the source & target accounts
await prisma.partner.delete({
where: {
@@ -384,6 +378,29 @@ const mergeAccounts = async ({ userId }: { userId: string }) => {
partnerId: targetPartnerId,
},
}),
+
+ resend?.batch.send([
+ {
+ from: VARIANT_TO_FROM_MAP.notifications,
+ to: sourceEmail,
+ subject: "Your Dub partner accounts are now merged",
+ react: PartnerAccountMerged({
+ email: sourceEmail,
+ sourceEmail,
+ targetEmail,
+ }),
+ },
+ {
+ from: VARIANT_TO_FROM_MAP.notifications,
+ to: targetEmail,
+ subject: "Your Dub partner accounts are now merged",
+ react: PartnerAccountMerged({
+ email: targetEmail,
+ sourceEmail,
+ targetEmail,
+ }),
+ },
+ ]),
]),
);
};
diff --git a/packages/email/src/templates/partner-account-merged.tsx b/packages/email/src/templates/partner-account-merged.tsx
new file mode 100644
index 0000000000..24bed14d67
--- /dev/null
+++ b/packages/email/src/templates/partner-account-merged.tsx
@@ -0,0 +1,67 @@
+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 PartnerAccountMerged({
+ email = "[email protected]",
+ sourceEmail = "[email protected]",
+ targetEmail = "[email protected]",
+}: {
+ email: string;
+ sourceEmail: string;
+ targetEmail: string;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>Your Dub partner accounts are now merged</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-10 max-w-[600px] px-10 py-5">
+ <Section className="mb-8 flex items-center">
+ <Img
+ src={DUB_WORDMARK}
+ height="32"
+ alt="Dub"
+ className="mr-auto"
+ />
+ </Section>
+
+ <Heading className="p-0 text-xl font-semibold text-black">
+ Your Dub partner accounts are now merged
+ </Heading>
+
+ <Text className="text-base text-neutral-600">
+ Your account <strong>{sourceEmail}</strong>, has been successfully
+ merged with <strong>{targetEmail}</strong>.
+ </Text>
+
+ <Text className="text-base text-neutral-600">
+ The merged account ({sourceEmail}) has been deleted. To use Dub
+ with that email, a new account will need to be created.
+ </Text>
+
+ <Text className="text-base text-neutral-600">
+ Contact <Link href="mailto:[email protected]">support</Link> if you
+ have any questions.
+ </Text>
+
+ <Footer email={email} />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}