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.

rename

Steven Teyb0a4da85f807
diff --git a/apps/web/app/api/cron/domains/verify/utils.ts b/apps/web/app/api/cron/domains/verify/utils.ts
index aab6504d9e..b8b818c031 100644
--- a/apps/web/app/api/cron/domains/verify/utils.ts
+++ b/apps/web/app/api/cron/domains/verify/utils.ts
@@ -63,7 +63,7 @@ export const handleDomainUpdates = async ({
isMachine: false,
},
notificationPreference: {
- domainConfigurationWarnings: true,
+ domainConfigurationUpdates: true,
},
},
},
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts
index 949d3110b5..626c53619e 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/invites/accept/route.ts
@@ -67,7 +67,7 @@ export const POST = withSession(async ({ session, params }) => {
role: "member",
projectId: workspace.id,
notificationPreference: {
- create: {},
+ create: {}, // by default, users are opted in to all notifications
},
},
}),
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 53f3314a94..339935198c 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
@@ -6,7 +6,7 @@ import { NextResponse } from "next/server";
export const GET = withWorkspace(async ({ workspace, session }) => {
const response = await prisma.notificationPreference.findFirstOrThrow({
select: {
- domainConfigurationWarnings: true,
+ domainConfigurationUpdates: true,
linkUsageSummary: true,
},
where: {
@@ -17,5 +17,7 @@ export const GET = withWorkspace(async ({ workspace, session }) => {
},
});
+ console.log({ response });
+
return NextResponse.json(response);
});
diff --git a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
index 4247d922c3..fe70854c21 100644
--- a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
+++ b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
@@ -110,7 +110,7 @@ async function VerifyInvite({ code }: { code: string }) {
userId: session.user.id,
projectId: workspace.id,
notificationPreference: {
- create: {},
+ create: {}, // by default, users are opted in to all notifications
},
},
});
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/preferences.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/preferences.tsx
index d6dbf91b76..7b56d742b9 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/preferences.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/notifications/preferences.tsx
@@ -2,6 +2,7 @@
import { updateNotificationPreference } from "@/lib/actions/update-notification-preference";
import useWorkspace from "@/lib/swr/use-workspace";
+import { Switch } from "@dub/ui";
import { LoadingSpinner } from "@dub/ui/src/icons";
import { fetcher } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
@@ -14,7 +15,7 @@ const notifications = [
description: "Monthly links usage summary",
},
{
- type: "domainConfigurationWarnings",
+ type: "domainConfigurationUpdates",
description: "Domain configuration warnings",
},
];
@@ -36,8 +37,10 @@ export const NotificationPreferences = () => {
mutate,
} = useSWR<{
linkUsageSummary: boolean;
- domainConfigurationWarnings: boolean;
- }>(`/api/workspaces/${workspaceId}/notification-preferences`, fetcher);
+ domainConfigurationUpdates: boolean;
+ }>(`/api/workspaces/${workspaceId}/notification-preferences`, fetcher, {
+ dedupingInterval: 30000,
+ });
return (
<>
@@ -95,12 +98,7 @@ const Preference = ({
return (
<div key={type}>
<label className="flex items-center font-medium text-gray-700">
- <input
- type="checkbox"
- className="h-4 w-4 border-gray-300 text-black focus:outline-none focus:ring-0"
- onChange={(e) => onChange(e.target.checked)}
- checked={enabled}
- />
+ <Switch checked={enabled} fn={(value) => onChange(value)} />
<span className="ml-2 text-sm text-gray-500">{description}</span>
</label>
</div>
diff --git a/apps/web/lib/actions/update-notification-preference.ts b/apps/web/lib/actions/update-notification-preference.ts
index fc6b2fb98d..f5dbeefe2e 100644
--- a/apps/web/lib/actions/update-notification-preference.ts
+++ b/apps/web/lib/actions/update-notification-preference.ts
@@ -6,7 +6,7 @@ import { authActionClient } from "./safe-action";
const schema = z.object({
workspaceId: z.string(),
- type: z.enum(["linkUsageSummary", "domainConfigurationWarnings"]),
+ type: z.enum(["linkUsageSummary", "domainConfigurationUpdates"]),
value: z.boolean(),
});
diff --git a/apps/web/prisma/schema/workspace.prisma b/apps/web/prisma/schema/workspace.prisma
index 5eaa1ae5b5..8d2723f7df 100644
--- a/apps/web/prisma/schema/workspace.prisma
+++ b/apps/web/prisma/schema/workspace.prisma
@@ -85,7 +85,7 @@ model NotificationPreference {
id String @id @default(cuid())
projectUserId String @unique
linkUsageSummary Boolean @default(true)
- domainConfigurationWarnings Boolean @default(true)
+ domainConfigurationUpdates Boolean @default(true)
projectUser ProjectUsers @relation(fields: [projectUserId], references: [id], onDelete: Cascade)
}