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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 34x 1108x 60x 60x 60x 1108x 60x 3x | import { QKEY_GET_ALL_CATEGORIES_CODES } from "@constants/queryKeys";
import { ROWS_PER_PAGE } from "@hooks/common/usePagination";
import { customInstance } from "@services/api";
import { useQuery } from "react-query";
interface Props {
page?: number;
max?: number;
all?: boolean;
searchTerm?: string;
}
export const useGetGlobalMerchantCategories = ({
page = 0,
max = ROWS_PER_PAGE,
all = false,
searchTerm = "",
}: Props) => {
const getCategories = () => {
Iif (searchTerm) {
return customInstance({
method: "GET",
url: `/category-codes?q=${searchTerm}&page=${page}&max=${max}`,
});
}
Iif (all) {
return customInstance({
method: "GET",
url: "/category-codes?page=0&max=0",
});
}
return customInstance({
method: "GET",
url: `/category-codes?page=${page}&max=${max}`,
});
};
return useQuery([QKEY_GET_ALL_CATEGORIES_CODES, page, searchTerm], async () => {
const data = await getCategories();
return data;
});
};
|