import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; import { useState } from "react"; import { useWatch } from "react-hook-form"; import classNames from "@calcom/lib/classNames"; import showToast from "@calcom/lib/notification"; import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Icon } from "@calcom/ui/Icon"; import { InputGroupBox } from "@calcom/ui/form/fields"; import { useLocale } from "@lib/hooks/useLocale"; export default function WebhookTestDisclosure() { const subscriberUrl: string = useWatch({ name: "subscriberUrl" }); const payloadTemplate = useWatch({ name: "payloadTemplate" }) || null; const { t } = useLocale(); const [open, setOpen] = useState(false); const mutation = trpc.useMutation("viewer.webhook.testTrigger", { onError(err) { showToast(err.message, "error"); }, }); return ( setOpen(!open)}> {t("webhook_test")}

{t("webhook_response")}

{!mutation.data && {t("no_data_yet")}} {mutation.status === "success" && ( <>
{mutation.data.ok ? t("success") : t("failed")}
{JSON.stringify(mutation.data, null, 4)}
)}
); }