23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
"use client";
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { apiFetch } from "@/lib/api";
|
|
import type { ConnectionPointsResponse } from "@/types/nspd";
|
|
|
|
export type { ConnectionPointsResponse };
|
|
|
|
export function useConnectionPoints(
|
|
cadNum: string | null | undefined,
|
|
enabled = true,
|
|
) {
|
|
return useQuery<ConnectionPointsResponse>({
|
|
queryKey: ["connection-points", cadNum],
|
|
queryFn: () =>
|
|
apiFetch<ConnectionPointsResponse>(
|
|
`/api/v1/parcels/${encodeURIComponent(cadNum!)}/connection-points`,
|
|
),
|
|
enabled: !!cadNum && enabled,
|
|
staleTime: 5 * 60 * 1000,
|
|
});
|
|
}
|