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 newPartnerApplication to notification preference

Kiran K677882bb9d50
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
index 4534df78f1..168bf59da0 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
@@ -9,6 +9,7 @@ export const GET = withWorkspace(async ({ workspace, session }) => {
domainConfigurationUpdates: true,
linkUsageSummary: true,
newPartnerSale: true,
+ newPartnerApplication: true,
},
where: {
projectUser: {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/page-client.tsx
index 5f64ee0cbd..2f881ed1e4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/page-client.tsx
@@ -4,7 +4,7 @@ import { updateNotificationPreference } from "@/lib/actions/update-notification-
import useWorkspace from "@/lib/swr/use-workspace";
import { notificationTypes } from "@/lib/zod/schemas/workspaces";
import { Switch, useOptimisticUpdate } from "@dub/ui";
-import { Globe, Hyperlink } from "@dub/ui/icons";
+import { Globe, Hyperlink, UserPlus } from "@dub/ui/icons";
import { DollarSign } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
import { useMemo } from "react";
@@ -34,6 +34,13 @@ export default function NotificationsSettingsPageClient() {
},
...(partnersEnabled
? [
+ {
+ type: "newPartnerApplication",
+ icon: UserPlus,
+ title: "New partner application",
+ description:
+ "Alert when a new partner application is made in your partner program.",
+ },
{
type: "newPartnerSale",
icon: DollarSign,
diff --git a/apps/web/lib/actions/partners/create-program-application.ts b/apps/web/lib/actions/partners/create-program-application.ts
index 777fe0e5de..d921135110 100644
--- a/apps/web/lib/actions/partners/create-program-application.ts
+++ b/apps/web/lib/actions/partners/create-program-application.ts
@@ -120,9 +120,9 @@ async function createApplicationAndEnrollment({
const workspaceUsers = await prisma.projectUsers.findMany({
where: {
projectId: program.workspaceId,
- // notificationPreference: {
- // newPartnerSale: true, // TODO: change to newPartnerApplication
- // },
+ notificationPreference: {
+ newPartnerApplication: true,
+ },
},
include: {
user: {
@@ -138,7 +138,7 @@ async function createApplicationAndEnrollment({
limiter.schedule(() =>
sendEmail({
subject: `New partner application for ${program.name}.`,
- email: "[email protected]", //partner.email!,
+ email: user.email!,
react: PartnerApplicationReceived({
email: partner.email!,
partner: {
@@ -152,6 +152,7 @@ async function createApplicationAndEnrollment({
},
program: {
id: program.id,
+ name: program.name,
},
}),
}),
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index ae12e64612..c0cd096e8f 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -143,4 +143,5 @@ export const notificationTypes = z.enum([
"linkUsageSummary",
"domainConfigurationUpdates",
"newPartnerSale",
+ "newPartnerApplication",
]);
diff --git a/packages/email/src/templates/partner-application-received.tsx b/packages/email/src/templates/partner-application-received.tsx
index 773d0c531a..c72d3b22d5 100644
--- a/packages/email/src/templates/partner-application-received.tsx
+++ b/packages/email/src/templates/partner-application-received.tsx
@@ -1,4 +1,4 @@
-import { DUB_WORDMARK } from "@dub/utils";
+import { DICEBEAR_AVATAR_URL, DUB_WORDMARK } from "@dub/utils";
import {
Body,
Container,
@@ -30,6 +30,7 @@ export function PartnerApplicationReceived({
},
program = {
id: "prog_CYCu7IMAapjkRpTnr8F1azjN",
+ name: "Acme",
},
}: {
email: string;
@@ -44,6 +45,7 @@ export function PartnerApplicationReceived({
};
program: {
id: string;
+ name: string;
};
}) {
const applicationUrl = `https://app.dub.co/acme/programs/${program.id}/partners?partnerId=${partner.id}`;
@@ -65,7 +67,7 @@ export function PartnerApplicationReceived({
<Text className="text-sm leading-6 text-neutral-600">
You have a new pending application to review, view their
- application below and or{" "}
+ application below or{" "}
<Link
href={applicationUrl}
className="text-neutral-600 underline underline-offset-4"
@@ -76,42 +78,36 @@ export function PartnerApplicationReceived({
</Text>
<Container className="mb-8 mt-10 rounded-lg border border-solid border-neutral-200">
- <Section className="p-4">
- <Container className="mb-4 w-full rounded-lg bg-[#f9fafb] p-6">
+ <Section className="p-2">
+ <Container className="mb-4 w-full rounded-lg border border-solid border-neutral-100 bg-neutral-50 p-6">
<div>
- <div
- style={{
- position: "relative",
- marginBottom: "16px",
- display: "inline-block",
- }}
- >
+ <div className="relative w-fit">
<Img
- src={partner.image ?? undefined}
- width="64"
- height="64"
+ src={
+ partner.image ||
+ `${DICEBEAR_AVATAR_URL}${partner.name}`
+ }
+ width="48"
+ height="48"
alt={partner.name}
- style={{ borderRadius: "9999px" }}
+ className="rounded-full"
/>
{partner.country && (
- <Img
- src={`https://flag.vercel.app/${partner.country}.svg`}
- width="18"
- height="18"
- alt={partner.country}
- style={{
- position: "absolute",
- bottom: "0",
- right: "0",
- borderRadius: "50%",
- border: "2px solid white",
- }}
- />
+ <div className="absolute -right-1 top-0 overflow-hidden rounded-full bg-neutral-50 p-0.5">
+ <Img
+ src={`https://flag.vercel.app/m/${partner.country}.svg`}
+ width="12"
+ height="12"
+ alt={partner.country}
+ className="size-3 rounded-full"
+ />
+ </div>
)}
</div>
+
<div>
- <Text className="m-0 p-0 text-2xl font-medium text-black">
+ <Text className="m-0 p-0 text-lg font-medium text-neutral-900">
{partner.name}
</Text>
<Text className="m-0 p-0 text-sm text-neutral-500">
@@ -121,49 +117,38 @@ export function PartnerApplicationReceived({
</div>
</Container>
- <Section className="mb-6">
- <Text className="m-0 mb-2 p-0 text-base font-medium text-neutral-900">
- How do you plan on promoting Cal.com
- </Text>
- <Text className="m-0 p-0 leading-6 text-neutral-600">
- {partner.proposal}
- </Text>
- </Section>
-
- {partner.comments && (
+ <Section className="p-4">
<Section className="mb-6">
<Text className="m-0 mb-2 p-0 text-base font-medium text-neutral-900">
- Any additional question or comments{" "}
- <span className="font-normal text-neutral-500">
- (optional)
- </span>
+ How do you plan on promoting {program.name}
</Text>
<Text className="m-0 p-0 leading-6 text-neutral-600">
- {partner.comments}
+ {partner.proposal}
</Text>
</Section>
- )}
- <Section className="mt-8 text-center">
- <Link
- href={applicationUrl}
- style={{
- backgroundColor: "#111111",
- borderRadius: "6px",
- color: "#fff",
- display: "block",
- fontSize: "14px",
- fontWeight: "500",
- lineHeight: "100%",
- padding: "16px 0",
- textDecoration: "none",
- textAlign: "center",
- width: "100%",
- boxSizing: "border-box",
- }}
- >
- Review application on Dub
- </Link>
+ {partner.comments && (
+ <Section className="mb-6">
+ <Text className="m-0 mb-2 p-0 text-base font-medium text-neutral-900">
+ Any additional question or comments{" "}
+ <span className="font-normal text-neutral-500">
+ (optional)
+ </span>
+ </Text>
+ <Text className="m-0 p-0 leading-6 text-neutral-600">
+ {partner.comments}
+ </Text>
+ </Section>
+ )}
+
+ <Section className="mt-8 text-center">
+ <Link
+ href={applicationUrl}
+ className="box-border block w-full rounded-md bg-black px-0 py-4 text-center text-sm font-medium leading-none text-white no-underline"
+ >
+ Review application on Dub
+ </Link>
+ </Section>
</Section>
</Section>
</Container>
diff --git a/packages/prisma/schema/workspace.prisma b/packages/prisma/schema/workspace.prisma
index e7c9ab32ba..e566ab6563 100644
--- a/packages/prisma/schema/workspace.prisma
+++ b/packages/prisma/schema/workspace.prisma
@@ -120,6 +120,7 @@ model NotificationPreference {
linkUsageSummary Boolean @default(true)
domainConfigurationUpdates Boolean @default(true)
newPartnerSale Boolean @default(true)
+ newPartnerApplication Boolean @default(true)
projectUser ProjectUsers @relation(fields: [projectUserId], references: [id], onDelete: Cascade)
}