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.

Invite email and builder updates (#3748)

Marcus Farrelld1f3b2d748a7
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/invite-partner-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/invite-partner-sheet.tsx
index 9be232b019..3c46c3746d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/invite-partner-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/invite-partner-sheet.tsx
@@ -15,8 +15,8 @@ import { GroupSelector } from "@/ui/partners/groups/group-selector";
import { X } from "@/ui/shared/icons";
import {
AnimatedSizeContainer,
- BlurImage,
Button,
+ Gift,
InfoTooltip,
MultiValueInput,
type MultiValueInputRef,
@@ -24,12 +24,15 @@ import {
RichTextProvider,
RichTextToolbar,
Sheet,
+ Trophy,
useMediaQuery,
} from "@dub/ui";
+import { Lock } from "@dub/ui/icons";
import { cn, pluralize } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import {
Dispatch,
+ ReactNode,
SetStateAction,
useEffect,
useMemo,
@@ -458,7 +461,6 @@ function EmailPreview({
onCancel: () => void;
isSavingEmailData: boolean;
}) {
- const { program } = useProgram();
const { verifiedEmailDomain } = useEmailDomains();
const { isMobile } = useMediaQuery();
@@ -631,14 +633,7 @@ function EmailPreview({
{displayContent.subject}
</p>
</div>
- <div className="grid grid-cols-1 gap-3 p-4 pb-8">
- <BlurImage
- src={program?.logo || "https://assets.dub.co/wordmark.png"}
- alt={program?.name || "Dub"}
- className="my-1 size-8 rounded-full object-contain"
- width={48}
- height={48}
- />
+ <div className="grid grid-cols-1 gap-3 p-4 pb-6">
<h3 className="font-medium text-neutral-900">
{displayContent.title}
</h3>
@@ -655,11 +650,7 @@ function EmailPreview({
<RichTextArea />
</RichTextProvider>
</div>
- <Button
- type="button"
- text="Accept invite"
- className="mt-4 w-fit"
- />
+ <InvitePreviewProgramDetails />
</div>
</>
)}
@@ -668,6 +659,43 @@ function EmailPreview({
);
}
+function InvitePreviewProgramDetails() {
+ return (
+ <div className="mt-4 rounded-[10px] border border-blue-200 bg-blue-50 p-4 pt-3">
+ <div className="flex items-center justify-center gap-2 text-sm font-semibold text-blue-900">
+ <Lock className="size-4 text-blue-500" />
+ <span>Program details</span>
+ </div>
+
+ <div className="mt-3 grid grid-cols-2 gap-3">
+ <PreviewInfoCard icon={<Gift className="size-5" />} label="Eligible Rewards" />
+ <PreviewInfoCard icon={<Trophy className="size-5" />} label="Eligible Bounties" />
+ </div>
+
+ <Button
+ type="button"
+ text="View invite"
+ className="mt-3 h-9 w-full rounded-lg bg-neutral-900 font-semibold text-white hover:bg-neutral-900"
+ />
+ </div>
+ );
+}
+
+function PreviewInfoCard({
+ icon,
+ label,
+}: {
+ icon: ReactNode;
+ label: string;
+}) {
+ return (
+ <div className="flex flex-col items-center justify-center rounded-lg border border-blue-100 bg-blue-100 px-4 pb-3 pt-4 text-center text-blue-900">
+ <div className="mb-1.5">{icon}</div>
+ <div className="text-sm font-medium">{label}</div>
+ </div>
+ );
+}
+
export function InvitePartnerSheet({
isOpen,
...rest
diff --git a/apps/web/lib/actions/partners/bulk-invite-partners.ts b/apps/web/lib/actions/partners/bulk-invite-partners.ts
index a6d4da6b8d..ecf1670652 100644
--- a/apps/web/lib/actions/partners/bulk-invite-partners.ts
+++ b/apps/web/lib/actions/partners/bulk-invite-partners.ts
@@ -168,7 +168,7 @@ export const bulkInvitePartnersAction = authActionClient
);
}
- const rewardsAndBounties = await getGroupRewardsAndBounties({
+ const { rewards, bounties } = await getGroupRewardsAndBounties({
programId,
groupId: groupId || program.defaultGroupId,
});
@@ -195,13 +195,15 @@ export const bulkInvitePartnersAction = authActionClient
name: program.name,
slug: program.slug,
logo: program.logo,
+ website: program.url,
},
...(inviteEmailData?.subject && {
subject: inviteEmailData.subject,
}),
...(inviteEmailData?.title && { title: inviteEmailData.title }),
...(inviteEmailData?.body && { body: inviteEmailData.body }),
- ...rewardsAndBounties,
+ rewards,
+ bounties,
}),
})),
);
diff --git a/apps/web/lib/actions/partners/create-program.ts b/apps/web/lib/actions/partners/create-program.ts
index 339fd78d6e..2d322f53bd 100644
--- a/apps/web/lib/actions/partners/create-program.ts
+++ b/apps/web/lib/actions/partners/create-program.ts
@@ -306,6 +306,11 @@ async function invitePartner({
waitUntil(
(async () => {
+ const { rewards, bounties } = await getGroupRewardsAndBounties({
+ programId: program.id,
+ groupId: program.defaultGroupId,
+ });
+
await sendEmail({
subject: `${program.name} invited you to join Dub Partners`,
variant: "notifications",
@@ -318,11 +323,10 @@ async function invitePartner({
name: program.name,
slug: program.slug,
logo: program.logo,
+ website: program.url,
},
- ...(await getGroupRewardsAndBounties({
- programId: program.id,
- groupId: program.defaultGroupId,
- })),
+ rewards,
+ bounties,
}),
});
})(),
diff --git a/apps/web/lib/actions/partners/invite-partner-from-network.ts b/apps/web/lib/actions/partners/invite-partner-from-network.ts
index beeb43d057..ba61f41e59 100644
--- a/apps/web/lib/actions/partners/invite-partner-from-network.ts
+++ b/apps/web/lib/actions/partners/invite-partner-from-network.ts
@@ -92,7 +92,7 @@ export const invitePartnerFromNetworkAction = authActionClient
Promise.allSettled([
(async () => {
if (!partner.email) return;
- const rewardsAndBounties = await getGroupRewardsAndBounties({
+ const { rewards, bounties } = await getGroupRewardsAndBounties({
programId,
groupId: enrolledPartner.groupId || program.defaultGroupId,
});
@@ -107,8 +107,10 @@ export const invitePartnerFromNetworkAction = authActionClient
name: program.name,
slug: program.slug,
logo: program.logo,
+ website: program.url,
},
- ...rewardsAndBounties,
+ rewards,
+ bounties,
}),
});
})(),
diff --git a/apps/web/lib/actions/partners/invite-partner.ts b/apps/web/lib/actions/partners/invite-partner.ts
index 9869437d69..e359cf1bb9 100644
--- a/apps/web/lib/actions/partners/invite-partner.ts
+++ b/apps/web/lib/actions/partners/invite-partner.ts
@@ -83,7 +83,7 @@ export const invitePartnerAction = authActionClient
const sendPartnerInvitePromise = (async () => {
try {
- const rewardsAndBounties = await getGroupRewardsAndBounties({
+ const { rewards, bounties } = await getGroupRewardsAndBounties({
programId,
groupId: enrolledPartner.groupId || program.defaultGroupId,
});
@@ -107,13 +107,15 @@ export const invitePartnerAction = authActionClient
name: program.name,
slug: program.slug,
logo: program.logo,
+ website: program.url,
},
...(inviteEmailData?.subject && {
subject: inviteEmailData.subject,
}),
...(inviteEmailData?.title && { title: inviteEmailData.title }),
...(inviteEmailData?.body && { body: inviteEmailData.body }),
- ...rewardsAndBounties,
+ rewards,
+ bounties,
}),
});
} catch (error) {
diff --git a/apps/web/lib/actions/partners/resend-program-invite.ts b/apps/web/lib/actions/partners/resend-program-invite.ts
index 701700dde1..2e5ff38c85 100644
--- a/apps/web/lib/actions/partners/resend-program-invite.ts
+++ b/apps/web/lib/actions/partners/resend-program-invite.ts
@@ -58,6 +58,12 @@ export const resendProgramInviteAction = authActionClient
await Promise.allSettled([
(async () => {
+ const { group, rewards, bounties } = await getGroupRewardsAndBounties({
+ programId,
+ groupId: programEnrollment.groupId || program.defaultGroupId,
+ });
+ const programWebsite = group.partnerGroupDefaultLinks[0]?.url;
+
await sendEmail({
subject: `${program.name} invited you to join Dub Partners`,
variant: "notifications",
@@ -70,11 +76,10 @@ export const resendProgramInviteAction = authActionClient
name: program.name,
slug: program.slug,
logo: program.logo,
+ website: programWebsite,
},
- ...(await getGroupRewardsAndBounties({
- programId,
- groupId: programEnrollment.groupId || program.defaultGroupId,
- })),
+ rewards,
+ bounties,
}),
});
})(),
diff --git a/packages/email/src/templates/program-invite.tsx b/packages/email/src/templates/program-invite.tsx
index dd2e26a9cb..c4282e3814 100644
--- a/packages/email/src/templates/program-invite.tsx
+++ b/packages/email/src/templates/program-invite.tsx
@@ -1,4 +1,4 @@
-import { DUB_WORDMARK } from "@dub/utils";
+import { DUB_WORDMARK, getPrettyUrl } from "@dub/utils";
import {
Body,
Column,
@@ -106,7 +106,8 @@ export default function ProgramInvite({
program = {
name: "Acme",
slug: "acme",
- logo: DUB_WORDMARK,
+ logo: "https://assets.dub.co/misc/acme-logo.png",
+ website: "https://acme.dub.sh",
},
rewards = [
{
@@ -138,6 +139,7 @@ export default function ProgramInvite({
name: string;
slug: string;
logo: string | null;
+ website?: string | null;
};
rewards: { icon: string; label: string }[] | null;
bounties: { icon: string; label: string }[] | null;
@@ -157,11 +159,7 @@ export default function ProgramInvite({
<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="mb-8 mt-6">
- <Img
- src={program.logo || "https://assets.dub.co/wordmark.png"}
- height="32"
- alt={program.name}
- />
+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />
</Section>
<Heading className="bt-5 mx-0 mt-10 p-0 text-lg font-medium text-black">
@@ -195,22 +193,42 @@ export default function ProgramInvite({
</>
)}
- <Section className="my-8">
- <Link
- className="rounded-lg bg-neutral-900 px-4 py-3 text-xs font-semibold text-white no-underline"
- href={`https://partners.dub.co/${program.slug}/register?email=${encodeURIComponent(email)}&next=/programs/${program.slug}/invite`}
- >
- Accept Invite
- </Link>
- </Section>
-
- {Boolean(rewards?.length || bounties?.length) && (
- <>
- <Text className="text-sm leading-6 text-neutral-600">
- If you accept the invite, you're immediately eligible for the
- following:
- </Text>
- <Section className="rounded-xl border border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
+ <>
+ <Text className="text-sm leading-6 text-neutral-600">
+ Here’s more details about the program and what you’ll be
+ eligible to earn:
+ </Text>
+ <Section className="overflow-hidden rounded-xl border border-solid border-neutral-200 bg-white">
+ <Section className="px-5 py-4">
+ <Row>
+ <Column className="w-[48px] align-top">
+ <Img
+ src={
+ program.logo ||
+ "https://assets.dub.co/misc/acme-logo.png"
+ }
+ width="40"
+ height="40"
+ alt={program.name}
+ className="rounded-full"
+ />
+ </Column>
+ <Column className="w-full pl-3">
+ <Text className="my-0 text-base font-semibold leading-5 text-black">
+ {program.name}
+ </Text>
+ {program.website && (
+ <Link
+ href={program.website}
+ className="mt-0 block text-xs font-medium leading-4 text-neutral-500 underline"
+ >
+ {getPrettyUrl(program.website)}
+ </Link>
+ )}
+ </Column>
+ </Row>
+ </Section>
+ <Section className="rounded-xl border-t border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
{rewards && Boolean(rewards.length) && (
<>
<Text className="my-0 text-base font-semibold text-black">
@@ -251,9 +269,15 @@ export default function ProgramInvite({
))}
</>
)}
+ <Link
+ className="mt-5 block rounded-lg bg-neutral-900 px-4 py-3 text-center text-xs font-semibold text-white no-underline"
+ href={`https://partners.dub.co/${program.slug}/register?email=${encodeURIComponent(email)}&next=/programs/${program.slug}/invite`}
+ >
+ View invite
+ </Link>
</Section>
- </>
- )}
+ </Section>
+ </>
<Footer email={email} />
</Container>
diff --git a/packages/email/src/templates/program-network-invite.tsx b/packages/email/src/templates/program-network-invite.tsx
index 05593247f9..f90b47b883 100644
--- a/packages/email/src/templates/program-network-invite.tsx
+++ b/packages/email/src/templates/program-network-invite.tsx
@@ -1,4 +1,4 @@
-import { DUB_WORDMARK } from "@dub/utils";
+import { DUB_WORDMARK, getPrettyUrl } from "@dub/utils";
import {
Body,
Column,
@@ -22,7 +22,8 @@ export default function ProgramNetworkInvite({
program = {
name: "Acme",
slug: "acme",
- logo: DUB_WORDMARK,
+ logo: "https://assets.dub.co/misc/acme-logo.png",
+ website: "https://acme.dub.sh",
},
rewards = [
{
@@ -51,6 +52,7 @@ export default function ProgramNetworkInvite({
name: string;
slug: string;
logo: string | null;
+ website?: string | null;
};
rewards: { icon: string; label: string }[] | null;
bounties: { icon: string; label: string }[] | null;
@@ -63,11 +65,7 @@ export default function ProgramNetworkInvite({
<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="mb-8 mt-6">
- <Img
- src={program.logo || "https://assets.dub.co/wordmark.png"}
- height="32"
- alt={program.name}
- />
+ <Img src={DUB_WORDMARK} height="32" alt="Dub" />
</Section>
<Heading className="mx-0 mt-10 p-0 text-lg font-medium text-black">
@@ -80,22 +78,42 @@ export default function ProgramNetworkInvite({
you to join their partner program.
</Text>
- <Section className="my-8">
- <Link
- className="rounded-lg bg-neutral-900 px-4 py-3 text-[12px] font-semibold text-white no-underline"
- href={`https://partners.dub.co/${program.slug}/register?email=${encodeURIComponent(email)}&next=/programs/${program.slug}`}
- >
- Accept Invite
- </Link>
- </Section>
-
- {Boolean(rewards?.length || bounties?.length) && (
- <>
- <Text className="text-sm leading-6 text-neutral-600">
- If you accept the invite, you're immediately eligible for the
- following:
- </Text>
- <Section className="rounded-xl border border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
+ <>
+ <Text className="text-sm leading-6 text-neutral-600">
+ Here’s more details about the program and what you’ll be
+ eligible to earn:
+ </Text>
+ <Section className="overflow-hidden rounded-xl border border-solid border-neutral-200 bg-white">
+ <Section className="px-5 py-4">
+ <Row>
+ <Column className="w-[48px] align-top">
+ <Img
+ src={
+ program.logo ||
+ "https://assets.dub.co/misc/acme-logo.png"
+ }
+ width="40"
+ height="40"
+ alt={program.name}
+ className="rounded-full"
+ />
+ </Column>
+ <Column className="w-full pl-3">
+ <Text className="my-0 text-base font-semibold leading-5 text-black">
+ {program.name}
+ </Text>
+ {program.website && (
+ <Link
+ href={program.website}
+ className="mt-0 block text-xs font-medium leading-4 text-neutral-500 underline"
+ >
+ {getPrettyUrl(program.website)}
+ </Link>
+ )}
+ </Column>
+ </Row>
+ </Section>
+ <Section className="rounded-xl border-t border-solid border-neutral-200 bg-neutral-50 px-5 py-4">
{rewards && Boolean(rewards.length) && (
<>
<Text className="my-0 text-base font-semibold text-black">
@@ -136,9 +154,15 @@ export default function ProgramNetworkInvite({
))}
</>
)}
+ <Link
+ className="mt-5 block rounded-lg bg-neutral-900 px-4 py-3 text-center text-[12px] font-semibold text-white no-underline"
+ href={`https://partners.dub.co/${program.slug}/register?email=${encodeURIComponent(email)}&next=/programs/${program.slug}`}
+ >
+ View invite
+ </Link>
</Section>
- </>
- )}
+ </Section>
+ </>
<Footer email={email} />
</Container>
</Body>