import { useWatch } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui/Icon"; import { Badge } from "@calcom/ui/components/badge"; import { Button } from "@calcom/ui/components/button"; import showToast from "@calcom/ui/v2/core/notifications"; export default function WebhookTestDisclosure() { const subscriberUrl: string = useWatch({ name: "subscriberUrl" }); const payloadTemplate = useWatch({ name: "payloadTemplate" }) || null; const { t } = useLocale(); const mutation = trpc.viewer.webhook.testTrigger.useMutation({ 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)}
)}
); }