import { useQuery } from "@tanstack/react-query";

import { QUERY_KEYS } from "@/constants/QUERY_KEYS";
import { overviewService } from "@/services/overview.service";
import type { OverviewRange } from "@/types/overview";

export function useOverview(range: OverviewRange = "30d") {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.dashboard(range),
    queryFn: () => overviewService.getDashboard(range),
  });
}

export function useOverviewBookingsTab(range: OverviewRange, enabled: boolean) {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.bookingsTab(range),
    queryFn: () => overviewService.getBookingsTab(range),
    enabled,
  });
}

export function useOverviewBillingTab(range: OverviewRange, enabled: boolean) {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.billingTab(range),
    queryFn: () => overviewService.getBillingTab(range),
    enabled,
  });
}

export function useOverviewOperationsTab(enabled: boolean) {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.operationsTab(),
    queryFn: () => overviewService.getOperationsTab(),
    enabled,
  });
}

export function useOverviewCustomersTab(range: OverviewRange, enabled: boolean) {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.customersTab(range),
    queryFn: () => overviewService.getCustomersTab(range),
    enabled,
  });
}

export function useOverviewStaffTab(range: OverviewRange, enabled: boolean) {
  return useQuery({
    queryKey: QUERY_KEYS.OVERVIEW.staffTab(range),
    queryFn: () => overviewService.getStaffTab(range),
    enabled,
  });
}
