Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Merge branch 'main' into 131/webhook
Marc Seitzf2489c19ce10
diff --cc components/settings/settings-header.tsxindex 87c1447e,8d911000..6776a6e9--- a/components/settings/settings-header.tsx+++ b/components/settings/settings-header.tsx@@@ -53,17 -53,16 +53,17 @@@ export function SettingsHeader()href: `/settings/presets`,segment: "presets",},+ {+ label: "Tags",+ href: `/settings/tags`,+ segment: "tags",+ },{- label: "Billing",- href: `/settings/billing`,- segment: "billing",+ label: "Webhooks",+ href: `/settings/webhooks`,+ segment: "webhooks",+ disabled: !features?.webhooks,},- {- label: "Billing",- href: `/settings/billing`,- segment: "billing",- },{label: "Tokens",href: `/settings/tokens`,@@@ -76,6 -81,6 +76,11 @@@segment: "incoming-webhooks",disabled: !features?.incomingWebhooks,},++ {++ label: "Billing",++ href: `/settings/billing`,++ segment: "billing",++ },]}/></header>diff --cc pages/settings/webhooks/new.tsxindex 71a074ea,8b92fdc6..c5fd4bae--- a/pages/settings/webhooks/new.tsx+++ b/pages/settings/webhooks/new.tsx@@@ -5,15 -5,13 +5,17 @@@ import { useRouter } from "next/router"import { useEffect, useState } from "react";import { useTeam } from "@/context/team-context";++import { PlanEnum } from "@/ee/stripe/constants";import { ArrowLeft, Check } from "lucide-react";import { toast } from "sonner";import useSWR from "swr";+import { z } from "zod";- import {- PlanEnum,- UpgradePlanModal,- } from "@/components/billing/upgrade-plan-modal";+ import { newId } from "@/lib/id-helper";++import { usePlan } from "@/lib/swr/use-billing";+ import { fetcher } from "@/lib/utils";+++import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";import AppLayout from "@/components/layouts/app";import { SettingsHeader } from "@/components/settings/settings-header";import Copy from "@/components/shared/icons/copy";@@@ -78,7 -63,6 +76,7 @@@ const formSchema = z.object(export default function NewWebhook() {const router = useRouter();const teamInfo = useTeam();- const { plan } = usePlan();++ const { isFree, isPro } = usePlan();const teamId = teamInfo?.currentTeam?.id;const [isLoading, setIsLoading] = useState(false);@@@ -96,32 -80,22 +94,37 @@@}, []);// Feature flag check-- const { data: features } = useSWR<{ webhooks: boolean }>(-- teamId ? `/api/feature-flags?teamId=${teamId}` : null,-- fetcher,-- );++ // 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]);++ // useEffect(() => {++ // if (features && !features.webhooks) {++ // router.push("/settings/general");++ // toast.error("This feature is not available on your plan");++ // }++ // }, [features, router]);const createWebhook = async () => {++ if (isFree || isPro) {++ toast.error("This feature is not available on your plan");++ return;++ }++try {setIsLoading(true);+ const result = formSchema.safeParse(formData);+ if (!result.success) {+ const errors = result.error.flatten().fieldErrors;+ Object.values(errors).forEach((errorMessages) => {+ if (errorMessages) {+ toast.error(errorMessages[0]);+ }+ });+ return;+ }const response = await fetch(`/api/teams/${teamId}/webhooks`, {method: "POST",headers: {@@@ -159,13 -133,13 +162,7 @@@</Button><div className="w-full max-w-3xl">-- <form-- onSubmit={(e) => {-- e.preventDefault();- if (plan !== "free") createWebhook();- createWebhook();-- }}-- className="space-y-8"-- >++ <form onSubmit={createWebhook} className="space-y-8"><div className="space-y-2"><Label htmlFor="name">Name</Label><p className="text-sm text-muted-foreground">@@@ -350,21 -326,9 +347,21 @@@</div><div className="flex space-x-4">- {plan === "free" ? (- <Button type="submit" disabled={isLoading}>- {isLoading ? "Creating..." : "Create Webhook"}- </Button>++ {isFree || isPro ? (+ <UpgradePlanModal+ key="create-webhook"+ clickedPlan={PlanEnum.Business}+ trigger="create_webhook"+ >+ <Button type="submit" disabled={isLoading}>+ Create Webhook+ </Button>+ </UpgradePlanModal>+ ) : (+ <Button type="submit" disabled={isLoading}>+ {isLoading ? "Creating..." : "Create Webhook"}+ </Button>+ )}<Buttontype="button"variant="outline"