Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: build in beta guards
Marc Seitz4ad2d23d24cc
diff --git a/pages/settings/webhooks/[id]/index.tsx b/pages/settings/webhooks/[id]/index.tsxindex ffe99582..f56d1a66 100644--- a/pages/settings/webhooks/[id]/index.tsx+++ b/pages/settings/webhooks/[id]/index.tsx@@ -36,6 +36,20 @@ export default function WebhookDetail() {const [isEditing, setIsEditing] = useState(false);const [isCopied, setIsCopied] = useState(false);+ // Feature flag check+ const { data: features } = useSWR<{ webhooks: boolean }>(+ teamId ? `/api/feature-flags?teamId=${teamId}` : null,+ fetcher,+ );++ // Redirect if feature is not enabled+ useEffect(() => {+ if (features && !features.webhooks) {+ router.push("/settings/general");+ toast.error("This feature is not available for your team");+ }+ }, [features, router]);+const { data: webhook, mutate } = useSWR<Webhook>(teamId && id ? `/api/teams/${teamId}/webhooks/${id}` : null,fetcher,diff --git a/pages/settings/webhooks/index.tsx b/pages/settings/webhooks/index.tsxindex b64bb86c..e1ddcae8 100644--- a/pages/settings/webhooks/index.tsx+++ b/pages/settings/webhooks/index.tsx@@ -1,6 +1,8 @@import Link from "next/link";import { useRouter } from "next/router";+import { useEffect } from "react";+import { useTeam } from "@/context/team-context";import { format } from "date-fns";import { CircleHelpIcon, CopyIcon, WebhookIcon } from "lucide-react";@@ -27,6 +29,20 @@ export default function WebhookSettings() {const teamInfo = useTeam();const teamId = teamInfo?.currentTeam?.id;+ // Feature flag check+ const { data: features } = useSWR<{ webhooks: boolean }>(+ teamId ? `/api/feature-flags?teamId=${teamId}` : null,+ fetcher,+ );++ // Redirect if feature is not enabled+ useEffect(() => {+ if (features && !features.webhooks) {+ router.push("/settings/general");+ toast.error("This feature is not available for your team");+ }+ }, [features, router]);+const { data: webhooks } = useSWR<Webhook[]>(teamId ? `/api/teams/${teamId}/webhooks` : null,fetcher,diff --git a/pages/settings/webhooks/new.tsx b/pages/settings/webhooks/new.tsxindex f71e53f3..0a5f7554 100644--- a/pages/settings/webhooks/new.tsx+++ b/pages/settings/webhooks/new.tsx@@ -7,6 +7,7 @@ import { useEffect, useState } from "react";import { useTeam } from "@/context/team-context";import { ArrowLeft, Check } from "lucide-react";import { toast } from "sonner";+import useSWR from "swr";import AppLayout from "@/components/layouts/app";import { SettingsHeader } from "@/components/settings/settings-header";@@ -18,6 +19,7 @@ import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { newId } from "@/lib/id-helper";+import { fetcher } from "@/lib/utils";interface WebhookEvent {id: string;@@ -77,6 +79,20 @@ export default function NewWebhook() {setFormData((prev) => ({ ...prev, secret: generatedSecret }));}, []);+ // Feature flag check+ const { data: features } = useSWR<{ webhooks: boolean }>(+ teamId ? `/api/feature-flags?teamId=${teamId}` : null,+ fetcher,+ );++ // Redirect if feature is not enabled+ useEffect(() => {+ if (features && !features.webhooks) {+ router.push("/settings/general");+ toast.error("This feature is not available for your team");+ }+ }, [features, router]);+const createWebhook = async () => {try {setIsLoading(true);