diff --git a/apps/dashboard/src/@/api/insight/webhooks.ts b/apps/dashboard/src/@/api/insight/webhooks.ts index f5101c258b1..0373bf32d00 100644 --- a/apps/dashboard/src/@/api/insight/webhooks.ts +++ b/apps/dashboard/src/@/api/insight/webhooks.ts @@ -41,12 +41,6 @@ export interface WebhookFilters { }; } -interface CreateWebhookPayload { - name: string; - webhook_url: string; - filters: WebhookFilters; -} - interface WebhooksListResponse { data: WebhookResponse[]; error?: string; @@ -57,56 +51,10 @@ interface WebhookSingleResponse { error?: string; } -interface TestWebhookPayload { - webhook_url: string; - type?: "event" | "transaction"; -} - -interface TestWebhookResponse { - success: boolean; - error?: string; -} - type SupportedWebhookChainsResponse = | { chains: Array } | { error: string }; -export async function createWebhook( - payload: CreateWebhookPayload, - clientId: string, -): Promise { - try { - const authToken = await getAuthToken(); - const response = await fetch( - `https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks`, - { - body: JSON.stringify(payload), - headers: { - Authorization: `Bearer ${authToken}`, - "Content-Type": "application/json", - "x-client-id": clientId, - }, - method: "POST", - }, - ); - - if (!response.ok) { - const errorText = await response.text(); - return { - data: null, - error: `Failed to create webhook: ${errorText}`, - }; - } - - return (await response.json()) as WebhookSingleResponse; - } catch (error) { - return { - data: null, - error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`, - }; - } -} - export async function getWebhooks( clientId: string, ): Promise { @@ -174,42 +122,6 @@ export async function deleteWebhook( } } -export async function testWebhook( - payload: TestWebhookPayload, - clientId: string, -): Promise { - try { - const authToken = await getAuthToken(); - const response = await fetch( - `https://${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks/test`, - { - body: JSON.stringify(payload), - headers: { - Authorization: `Bearer ${authToken}`, - "Content-Type": "application/json", - "x-client-id": clientId, - }, - method: "POST", - }, - ); - - if (!response.ok) { - const errorText = await response.text(); - return { - error: `Failed to test webhook: ${errorText}`, - success: false, - }; - } - - return (await response.json()) as TestWebhookResponse; - } catch (error) { - return { - error: `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`, - success: false, - }; - } -} - export async function getSupportedWebhookChains(): Promise { try { const response = await fetch( diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/BasicInfoStep.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/BasicInfoStep.tsx deleted file mode 100644 index 872c8802c68..00000000000 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/BasicInfoStep.tsx +++ /dev/null @@ -1,192 +0,0 @@ -"use client"; - -import { useId } from "react"; -import type { UseFormReturn } from "react-hook-form"; -import { Button } from "@/components/ui/button"; -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; -import { cn } from "@/lib/utils"; -import type { WebhookFormValues } from "../utils/webhookTypes"; - -interface BasicInfoStepProps { - form: UseFormReturn; - goToNextStep: () => void; - isLoading: boolean; -} - -export default function BasicInfoStep({ - form, - goToNextStep, - isLoading, -}: BasicInfoStepProps) { - const filterEventId = useId(); - const filterTransactionId = useId(); - return ( - <> -
-

Step 1: Basic Information

-

- Provide webhook details and select filter type -

-
- - ( - - - Name * - - - - - - - )} - /> - - ( - - - Webhook URL * - - - - - - - )} - /> - - ( - - - Filter Type * - - - { - if (value !== "event" && value !== "transaction") { - return; - } - field.onChange(value); - // Ensure the form state is updated immediately - form.setValue("filterType", value, { - shouldDirty: true, - shouldValidate: true, - }); - }} - value={field.value || undefined} - > -
-