import { PlusIcon } from "@heroicons/react/solid"; import { useState } from "react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogContent } from "@calcom/ui/Dialog"; import { QueryCell } from "@lib/QueryCell"; import { trpc } from "@lib/trpc"; import { List } from "@components/List"; import { ShellSubHeading } from "@components/Shell"; import SkeletonLoader from "@components/apps/SkeletonLoader"; import WebhookDialogForm from "@components/webhook/WebhookDialogForm"; import WebhookListItem, { TWebhook } from "@components/webhook/WebhookListItem"; export type WebhookListContainerType = { title: string; subtitle: string; eventTypeId?: number; }; export default function WebhookListContainer(props: WebhookListContainerType) { const query = trpc.useQuery(["viewer.webhook.list", { eventTypeId: props.eventTypeId }], { suspense: true, }); const [newWebhookModal, setNewWebhookModal] = useState(false); const [editModalOpen, setEditModalOpen] = useState(false); const [editing, setEditing] = useState(null); return ( } success={({ data }) => (
setNewWebhookModal(true)} data-testid="new_webhook" /> } /> {data.length ? ( {data.map((item) => ( { setEditing(item); setEditModalOpen(true); }} /> ))} ) : null} {/* New webhook dialog */} !isOpen && setNewWebhookModal(false)}> setNewWebhookModal(false)} /> {/* Edit webhook dialog */} !isOpen && setEditModalOpen(false)}> {editing && ( setEditModalOpen(false)} defaultValues={editing} /> )}
)} /> ); }