import { useWatch } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Badge, Button, showToast } from "@calcom/ui"; import { FiActivity } from "@calcom/ui/components/icon"; 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_test")}

{t("test_webhook")}

{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)}
)}
); }