import { queryOptions } from "@tanstack/react-query"; import { api } from "../apiHelper"; export function getCustomerByAv(av: string) { return queryOptions({ queryKey: ["getCustomerByAv", av], queryFn: () => dataFetch(av), staleTime: 5000, enabled: !!av, refetchOnWindowFocus: true, //placeholderData: keepPreviousData, }); } const dataFetch = async (av: string) => { if (window.location.hostname === "localhost") { await new Promise((res) => setTimeout(res, 1500)); } const { data } = await api.get(`/opendock/articleCheck/customers/${av}`); if (!data.success) { throw new Error(data.message ?? "Failed to load customers"); } return data.data ?? []; };