import type { SupabaseClient } from "@supabase/supabase-js";

export async function logProjectActivity(
  supabase: SupabaseClient,
  input: {
    userId: string | null;
    projectId: string | null | undefined;
    entityType: "project" | "task" | "note" | "link";
    entityId?: string | null;
    action: string;
    title: string;
    details?: Record<string, unknown>;
  }
) {
  if (!input.userId || !input.projectId) return;

  await supabase.from("project_activity").insert({
    user_id: input.userId,
    project_id: input.projectId,
    entity_type: input.entityType,
    entity_id: input.entityId || null,
    action: input.action,
    title: input.title,
    details: input.details || {},
  });
}
