import React, { useEffect } from 'react'; import { Loader, NoContent, Icon } from 'UI'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { toast } from 'react-toastify'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import { IWebhook } from 'Types/webhook'; import { App, List, Button, Typography, Space } from 'antd'; import { PencilIcon } from '.store/lucide-react-virtual-b029c146a4/package'; import usePageTitle from '@/hooks/usePageTitle'; import { useModal } from 'Components/ModalContext'; import WebhookForm from './WebhookForm'; import { useTranslation } from 'react-i18next'; function Webhooks() { const { t } = useTranslation(); const { settingsStore } = useStore(); const { webhooks, hooksLoading: loading } = settingsStore; const { openModal, closeModal } = useModal(); const { modal } = App.useApp(); usePageTitle('Webhooks - OpenReplay Preferences'); const customWebhooks = webhooks.filter((h) => h.type === 'webhook'); useEffect(() => { void settingsStore.fetchWebhooks(); }, []); const init = (w?: Partial) => { settingsStore.initWebhook({ ...w }); openModal(, { title: w ? t('Edit Webhook') : t('Add Webhook'), }); }; const removeWebhook = async (id: string) => { modal.confirm({ title: t('Confirm'), content: t('Are you sure you want to remove this webhook?'), onOk: () => { settingsStore .removeWebhook(id) .then(() => toast.success(t('Webhook removed successfully'))); closeModal(); }, }); }; return (
{t('Webhooks')} {t( 'Leverage webhook notifications on alerts to trigger custom callbacks.', )}
{t('None added yet')}
} size="small" show={customWebhooks.length === 0} > ( init(w)} className="p-2! group flex justify-between items-center cursor-pointer hover:bg-active-blue transition" > {w.name} {w.endpoint}