Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
ui update: Incoming webhook page
Ashish Viradiyae88648f301ff
diff --git a/pages/settings/incoming-webhooks.tsx b/pages/settings/incoming-webhooks.tsxindex fb4dfc27..28a46451 100644--- a/pages/settings/incoming-webhooks.tsx+++ b/pages/settings/incoming-webhooks.tsx@@ -1,18 +1,26 @@-import { useRouter } from "next/router";+import { useRouter } from "next/navigation";import { useEffect, useState } from "react";import { useTeam } from "@/context/team-context";import { format } from "date-fns";-import { CircleHelpIcon, CopyIcon } from "lucide-react";+import { CircleHelpIcon, CopyIcon, Loader } from "lucide-react";import { toast } from "sonner";import useSWR from "swr";import AppLayout from "@/components/layouts/app";import { SettingsHeader } from "@/components/settings/settings-header";import { Button } from "@/components/ui/button";+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";+import { Separator } from "@/components/ui/separator";import { BadgeTooltip } from "@/components/ui/tooltip";import { copyToClipboard, fetcher } from "@/lib/utils";@@ -29,6 +37,7 @@ export default function WebhookSettings() {const teamId = teamInfo?.currentTeam?.id;const router = useRouter();const [name, setName] = useState("");+ console.log("🚀 ~ WebhookSettings ~ name:", name);const [webhookId, setWebhookId] = useState<string | null>(null);const [isLoading, setIsLoading] = useState(false);@@ -107,95 +116,100 @@ export default function WebhookSettings() {<AppLayout><main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10"><SettingsHeader />-- <div className="rounded-lg border border-gray-200 bg-white">- <div className="flex flex-col items-center justify-between gap-4 space-y-3 border-b border-gray-200 p-5 sm:flex-row sm:space-y-0 sm:p-10">- <div className="flex max-w-screen-sm flex-col space-y-3">- <div className="flex items-center gap-2">- <h2 className="text-xl font-medium text-gray-900">- Incoming Webhooks- </h2>- <BadgeTooltip content="Use webhooks to receive data from external services">- <CircleHelpIcon className="h-4 w-4 text-gray-500" />- </BadgeTooltip>- </div>- <p className="text-sm text-gray-500">- Create incoming webhooks to receive data from external services- and automatically create new documents in Papermark.- </p>- </div>- </div>-- <div className="p-5 sm:p-10">- <div className="flex flex-col space-y-4">- <div>- <Label htmlFor="webhook-name" className="text-gray-900">- Webhook Name- </Label>- <Input- id="webhook-name"- placeholder="Enter a name for your webhook"- value={name}- onChange={(e) => setName(e.target.value)}- className="text-gray-900 dark:bg-white"- />- </div>-- {webhookId && (- <div className="rounded-lg bg-gray-50 p-4 text-gray-900">- <div className="flex items-center gap-2">- <Label>Your Webhook URL (copy it now)</Label>- <Button- variant="ghost"- size="icon"- className="h-6 w-6"- onClick={() =>- copyToClipboard(- `${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhookId}`,- "Webhook URL copied to clipboard",- )- }- >- <CopyIcon />- </Button>- </div>- <code className="mt-2 block break-all rounded bg-gray-100 p-2 font-mono text-sm">- {`${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhookId}`}- </code>+ <Card>+ <CardHeader>+ <CardTitle className="flex items-center gap-2">+ Incoming Webhooks+ <BadgeTooltip content="Use webhooks to receive data from external services">+ <CircleHelpIcon className="h-4 w-4 text-gray-500" />+ </BadgeTooltip>+ </CardTitle>+ <CardDescription>+ Create incoming webhooks to receive data from external services+ and automatically create new documents in Papermark.+ </CardDescription>+ </CardHeader>+ <Separator className="mb-6" />+ <CardContent>+ <div className="flex flex-col space-y-6">+ <div className="flex flex-col space-y-4">+ <div>+ <Label htmlFor="webhook-name">Webhook Name</Label>+ <Input+ id="webhook-name"+ placeholder="Enter a name for your webhook"+ value={name}+ onChange={(e) => setName(e.target.value)}+ /></div>- )}-- <Button- onClick={createWebhook}- disabled={!name || isLoading}- className="w-fit bg-gray-900 text-gray-50 hover:bg-gray-900/90"- >- {isLoading ? "Creating..." : "Create Webhook"}- </Button>+ {webhookId && (+ <Card>+ <CardHeader>+ <CardTitle className="flex items-center gap-2">+ <div className="flex items-center gap-2">+ <Label>Your Webhook URL (copy it now)</Label>+ <BadgeTooltip content="Use webhooks to receive data from external services">+ <CircleHelpIcon className="h-4 w-4 text-gray-500" />+ </BadgeTooltip>+ </div>+ </CardTitle>+ </CardHeader>+ <Separator className="mb-6" />+ <CardContent>+ <code className="mt-2 flex items-center break-all rounded bg-background p-2 font-mono text-sm dark:bg-gray-900">+ {`${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhookId}`}{" "}+ <Button+ variant="ghost"+ size="icon"+ className="ml-2 h-6 w-6"+ onClick={() =>+ copyToClipboard(+ `${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhookId}`,+ "Webhook URL copied to clipboard",+ )+ }+ >+ <CopyIcon />+ </Button>+ </code>+ </CardContent>+ </Card>+ )}+ <Button+ onClick={createWebhook}+ disabled={!name || isLoading}+ className="w-fit"+ >+ {isLoading ? "Creating..." : "Create Webhook"}+ </Button>+ </div>{/* Webhooks List */}- <div className="mt-8">- <h3 className="mb-4 text-lg font-medium text-gray-900">- Existing Webhooks- </h3>- <div className="rounded-lg border border-gray-200">+ <div>+ <h3 className="mb-4 text-lg font-medium">Existing Webhooks</h3>+ <Card className="min-h-14">+ {webhooks === undefined ? (+ <div className="flex w-full items-center justify-center p-4">+ <Loader className="h-5 w-5 animate-spin" />+ </div>+ ) : null}{webhooks?.length === 0 ? (- <div className="p-4 text-center text-sm text-gray-500">- No webhooks created yet+ <div className="flex w-full items-center justify-center p-4">+ <CardDescription>No webhooks created yet</CardDescription></div>) : (- <div className="divide-y divide-gray-200">+ <div className="divide-y divide-border">{webhooks?.map((webhook) => (<divkey={webhook.id}className="flex items-center justify-between p-4"><div className="space-y-1">- <p className="font-medium text-gray-900">+ <label className="font-medium">{webhook.name}- </p>- <div className="flex items-center space-x-2 text-sm text-gray-500">- <div className="flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-1.5 font-mono">+ </label>+ <div className="flex items-center space-x-2 text-sm text-muted-foreground">+ <div className="flex items-center gap-2 rounded-md border bg-background px-3 py-1.5 font-mono dark:bg-gray-900"><span className="max-w-[200px] overflow-x-auto whitespace-nowrap md:max-w-[400px]">{`${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhook.webhookId}`}</span>@@ -203,14 +217,16 @@ export default function WebhookSettings() {variant="ghost"size="icon"className="h-6 w-6"- onClick={() =>- copyToClipboard(+ onClick={() => {+ navigator.clipboard.writeText(`${process.env.NEXT_PUBLIC_WEBHOOK_BASE_URL}/services/${webhook.webhookId}`,+ );+ toast.success("Webhook URL copied to clipboard",- )- }+ );+ }}>- <CopyIcon />+ <CopyIcon className="h-3 w-3" /></Button></div><span>•</span>@@ -233,11 +249,11 @@ export default function WebhookSettings() {))}</div>)}- </div>+ </Card></div></div>- </div>- </div>+ </CardContent>+ </Card></main></AppLayout>);