"use client";

import type { WebhookEventType } from "@/types";

export async function emitWebhookEvent(input: {
  teamId: string | null;
  eventType: WebhookEventType;
  data: Record<string, unknown>;
}) {
  try {
    await fetch("/api/webhooks/emit", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(input),
    });
  } catch (error) {
    console.error("Webhook event emission failed", error);
  }
}
