"use client";

import { useQuery } from "@tanstack/react-query";
import { experienceApi } from "@/modules/experience/services/experience-api";

export function useExperienceCapabilities() {
  return useQuery({
    queryKey: ["experience", "capabilities"],
    queryFn: () => experienceApi.capabilities(),
    staleTime: 60_000,
  });
}

export function useExperienceHealth() {
  return useQuery({
    queryKey: ["experience", "health"],
    queryFn: () => experienceApi.health(),
  });
}

export function useExperienceMetrics() {
  return useQuery({
    queryKey: ["experience", "metrics"],
    queryFn: () => experienceApi.metrics(),
    staleTime: 30_000,
  });
}

export function useExperienceLookups(tenantId: string | null) {
  return useQuery({
    queryKey: ["experience", tenantId, "lookups"],
    queryFn: async () => {
      const [workspaces, sites] = await Promise.all([
        experienceApi.workspaces.list(tenantId!),
        experienceApi.sites.list(tenantId!),
      ]);
      return { workspaces, sites };
    },
    enabled: !!tenantId,
    staleTime: 30_000,
  });
}
