"use client";

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

export function useHospitalityCapabilities() {
  return useQuery({
    queryKey: ["hospitality", "capabilities"],
    queryFn: () => hospitalityApi.capabilities(),
    staleTime: 60_000,
  });
}

export function useHospitalityHealth() {
  return useQuery({
    queryKey: ["hospitality", "health"],
    queryFn: () => hospitalityApi.health(),
  });
}

export function useHospitalityLookups(tenantId: string | null) {
  return useQuery({
    queryKey: ["hospitality", tenantId, "lookups"],
    queryFn: async () => {
      const [venues, branches, menus] = await Promise.all([
        hospitalityApi.venues.list(tenantId!, { page: 1, page_size: 500 }),
        hospitalityApi.branches.list(tenantId!, { page: 1, page_size: 500 }),
        hospitalityApi.menus.list(tenantId!, { page: 1, page_size: 500 }),
      ]);
      return { venues, branches, menus };
    },
    enabled: !!tenantId,
    staleTime: 30_000,
  });
}
