"use client";

import { useQuery } from "@tanstack/react-query";
import {
  getTaskTemplatesGrouped,
  type TaskTemplatesGroupedResponse,
} from "@/lib/api/lookups";

/**
 * Fetches task templates grouped by category.
 * 30-minute staleTime since templates rarely change.
 */
export function useTaskTemplatesGrouped() {
  return useQuery<TaskTemplatesGroupedResponse>({
    queryKey: ["task-templates", "grouped"],
    queryFn: () => getTaskTemplatesGrouped(),
    staleTime: 30 * 60 * 1000, // 30 minutes
  });
}
