import { useWatch } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui/Icon"; import Badge from "@calcom/ui/v2/core/Badge"; import Button from "@calcom/ui/v2/core/Button"; export default function WebhookTestDisclosure() { const subscriberUrl: string = useWatch({ name: "subscriberUrl" }); const payloadTemplate = useWatch({ name: "payloadTemplate" }) || null; const { t } = useLocale(); const mutation = trpc.useMutation("viewer.webhook.testTrigger", { onError(err) { showToast(err.message, "error"); }, }); return (

{t("webhook_response")}

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