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 45 46 47 48 49 50 51 52 53 | import { Axios, AxiosInstance, AxiosRequestConfig } from "axios";
import { axiosInstance } from "../index";
import { customInstance } from "../index";
import { useQuery } from "react-query";
import { ROWS_PER_PAGE } from "@hooks/common/usePagination";
import { ProductParams, useQueryFactory } from "./queryFactory";
import { buildMerchantEndpoints } from "../utils.api";
export const addSweepstake = (query: any) => {
return customInstance({
url: "merchants/2/customers",
method: "POST",
data: query,
});
};
export const getSweepstake = ({
queryString,
page,
sorting,
searchQuery,
}: ProductParams) => {
const search = searchQuery ? `&q="${searchQuery}"` : "";
return customInstance({
url: buildMerchantEndpoints(
`products?filter=typeName:"sweepstake"${queryString}&sort=${
sorting ?? "-id"
}${search}&page=${page}&max=${ROWS_PER_PAGE}`,
),
method: "GET",
});
};
export const useGetSweepstake = useQueryFactory("sweepstake");
export const getProductById = (id: string) => {
return customInstance({
url: buildMerchantEndpoints(`products/${id}?filter=typeName:"sweepstake"`),
method: "GET",
});
};
export const useGetSweepstakeById = (id: string) => {
return useQuery(
["get-sweepstake-by-id", id],
async () => {
const data = await getProductById(id);
return data;
},
{ cacheTime: 0, refetchOnWindowFocus: false },
);
};
|