Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 2x 2x 1x 10x 1x 1x | import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { API } from "aws-amplify";
import { ReactQueryApiError } from "shared-types";
import { cpocs } from "shared-types/opensearch";
import { sendGAEvent } from "@/utils/ReactGA/SendGAEvent";
export async function fetchCpocData() {
try {
const response = await API.post("os", "/getCpocs", { body: {} });
const results = response.hits?.hits || [];
return results.map((hit: cpocs.ItemResult) => hit._source);
} catch (error) {
sendGAEvent("api_error", {
message: "failure /getCpocs",
});
console.error("Error fetching CPOCs:", error);
}
}
export function useGetCPOCs<T>(queryOptions?: UseQueryOptions<T[], ReactQueryApiError>) {
return useQuery<T[], ReactQueryApiError>(["package-cpocs"], () => fetchCpocData(), queryOptions);
}
|