"use client";

import { useQuery } from "@tanstack/react-query";
import { sportsCenterApi } from "@/modules/sports-center/services/sports-center-api";

export function useSportsCenterLookups(tenantId: string | null) {
  return useQuery({
    queryKey: ["sports-center", tenantId, "lookups"],
    queryFn: async () => {
      const [centers, branches, sports, members, coaches] = await Promise.all([
        sportsCenterApi.sportsCenters.list(tenantId!, { page: 1, page_size: 500 }),
        sportsCenterApi.branches.list(tenantId!, { page: 1, page_size: 500 }),
        sportsCenterApi.sports.list(tenantId!, { page: 1, page_size: 500 }),
        sportsCenterApi.members.list(tenantId!, { page: 1, page_size: 500 }),
        sportsCenterApi.coaches.list(tenantId!, { page: 1, page_size: 500 }),
      ]);
      return { centers, branches, sports, members, coaches };
    },
    enabled: !!tenantId,
    staleTime: 30_000,
  });
}
