import { apiGet } from './client';
import { useQuery } from '@tanstack/react-query';
import type { PluginUiManifest } from '../store/pluginStore';

export function useActivePluginManifests() {
  return useQuery({
    queryKey: ['plugin-active-manifests'],
    queryFn: async () => {
      const res = await apiGet<{ plugins: PluginUiManifest[]; total: number }>('/plugins/active-manifests');
      return res;
    },
    staleTime: 5 * 60 * 1000, // 5 min
    refetchOnMount: true,
  });
}
