Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions apps/dashboard/src/@/api/webhook-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,53 @@ export async function deleteWebhookConfig(props: {
status: "success",
};
}

type TestDestinationUrlResponse =
| {
result: {
httpStatusCode: number;
httpResponseBody: string;
};
status: "success";
}
| {
body: string;
reason: string;
status: "error";
};

export async function testDestinationUrl(props: {
teamIdOrSlug: string;
projectIdOrSlug: string;
destinationUrl: string;
}): Promise<TestDestinationUrlResponse> {
const authToken = await getAuthToken();

if (!authToken) {
return {
body: "Authentication required",
reason: "no_auth_token",
status: "error",
};
}

const resp = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${props.teamIdOrSlug}/projects/${props.projectIdOrSlug}/webhook-configs/test-destination-url`,
{
body: JSON.stringify({ destinationUrl: props.destinationUrl }),
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
},
method: "POST",
},
);
if (!resp.ok) {
return {
body: await resp.text(),
reason: "unknown",
status: "error",
};
}
return await resp.json();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WebhookConfigModal } from "./webhook-config-modal";
interface CreateWebhookConfigModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onSuccess: () => void;
teamSlug: string;
projectSlug: string;
topics: Topic[];
Expand All @@ -19,6 +20,7 @@ export function CreateWebhookConfigModal(props: CreateWebhookConfigModalProps) {
mode="create"
onOpenChange={props.onOpenChange}
open={props.open}
onSuccess={props.onSuccess}
projectSlug={props.projectSlug}
supportedChainIds={props.supportedChainIds}
teamSlug={props.teamSlug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WebhookConfigModal } from "./webhook-config-modal";
interface EditWebhookConfigModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onSuccess: () => void;
teamSlug: string;
projectSlug: string;
topics: Topic[];
Expand All @@ -20,6 +21,7 @@ export function EditWebhookConfigModal(props: EditWebhookConfigModalProps) {
mode="edit"
onOpenChange={props.onOpenChange}
open={props.open}
onSuccess={props.onSuccess}
projectSlug={props.projectSlug}
supportedChainIds={props.supportedChainIds}
teamSlug={props.teamSlug}
Expand Down
Loading
Loading