import { useEffect, useState } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import useSWR from "swr"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // layouts import { AppLayout } from "layouts/app-layout"; import { WorkspaceSettingLayout } from "layouts/settings-layout"; // components import { WorkspaceSettingHeader } from "components/headers"; import { DeleteWebhookModal, WebhookDeleteSection, WebhookForm } from "components/web-hooks"; // ui import { Spinner } from "@plane/ui"; // types import { NextPageWithLayout } from "types/app"; const WebhookDetailsPage: NextPageWithLayout = observer(() => { // states const [deleteWebhookModal, setDeleteWebhookModal] = useState(false); // router const router = useRouter(); const { workspaceSlug, webhookId, isCreated } = router.query; // mobx store const { webhook: { currentWebhook, clearSecretKey, fetchWebhookById }, user: { currentWorkspaceRole }, } = useMobxStore(); useEffect(() => { if (isCreated !== "true") clearSecretKey(); }, [clearSecretKey, isCreated]); const isAdmin = currentWorkspaceRole === 20; useSWR( workspaceSlug && webhookId && isAdmin ? `WEBHOOK_DETAILS_${workspaceSlug}_${webhookId}` : null, workspaceSlug && webhookId && isAdmin ? () => fetchWebhookById(workspaceSlug.toString(), webhookId.toString()) : null ); if (!isAdmin) return (
You are not authorized to access this page.