// frontend/lib/hooks/useConnectors.ts — SWR 커넥터 상태 목록
"use client";
import useSWR from "swr";
import type { ConnectorStatus } from "@/lib/types";
import { connectorsApi } from "@/lib/connectors/api";

export function useConnectors(domain = "") {
  const { data, error, isLoading, mutate } = useSWR<ConnectorStatus[]>(
    domain ? `/api/connectors?domain=${domain}` : "/api/connectors",
    () => connectorsApi.list(domain),
    { revalidateOnFocus: false },
  );
  return { data, isLoading, error, refresh: mutate };
}
