"use client"; import { useBookerUrl } from "@calcom/features/bookings/hooks/useBookerUrl"; import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { RouterOutputs } from "@calcom/trpc/react"; import { Avatar, AvatarImage } from "@coss/ui/components/avatar"; import { Card, CardFrame, CardFrameHeader, CardPanel } from "@coss/ui/components/card"; import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "@coss/ui/components/empty"; import { AppHeader, AppHeaderActions, AppHeaderContent, AppHeaderDescription, } from "@coss/ui/shared/app-header"; import { WebhookIcon } from "lucide-react"; import { useRouter } from "next/navigation"; import { CreateNewWebhookButton, WebhookListItem } from "../components"; type WebhooksByViewer = RouterOutputs["viewer"]["webhook"]["getByViewer"]; type Props = { data: WebhooksByViewer; }; const WebhooksView = ({ data }: Props) => { return (
); }; const WebhooksList = ({ webhooksByViewer }: { webhooksByViewer: WebhooksByViewer }) => { const { t } = useLocale(); const router = useRouter(); const { webhookGroups } = webhooksByViewer; const bookerUrl = useBookerUrl(); return ( <> {t("add_webhook_description", { appName: APP_NAME })} {webhookGroups.length > 0 && ( )}
{webhookGroups.length ? ( webhookGroups.map((group) => { const userName = group.profile.name ?? group.profile.slug ?? ""; const userAvatar = group.profile.image ?? (group.profile.slug ? `${bookerUrl}/${group.profile.slug}/avatar.png` : undefined); return (
{userAvatar ? : null} {userName}
{[...group.webhooks] .sort((a, b) => a.id.localeCompare(b.id)) .map((webhook) => ( router.push(`${WEBAPP_URL}/settings/developer/webhooks/${webhook.id}`) } /> ))}
); }) ) : ( {t("create_your_first_webhook")} {t("create_your_first_webhook_description", { appName: APP_NAME })} )}
); }; export default WebhooksView;