import { useQuery } from '@tanstack/react-query';
import { api } from '@/lib/api/client';

interface ModuleSettings {
  [key: string]: any;
}

/**
 * Hook to fetch module settings
 */
export function useModuleSettings(moduleId: string) {
  const { data, isLoading } = useQuery<ModuleSettings>({
    queryKey: ['module-settings', moduleId],
    queryFn: async () => {
      const response = await api.get(`/modules/${moduleId}/settings`);
      return response || {};
    },
    staleTime: 5 * 60 * 1000, // Cache for 5 minutes
  });

  return {
    settings: data || {},
    isLoading,
  };
}
