changed file name
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// imports
|
||||
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
|
||||
|
||||
// types
|
||||
|
||||
export type GetAllOrdersResponse = ApiPaginated<Order>;
|
||||
|
||||
export type GetAllOrdersRequest = {
|
||||
sort: string | undefined;
|
||||
status: string | undefined;
|
||||
page: string | string[];
|
||||
};
|
||||
|
||||
const useGetAllOrders = (params: ComputedRef<GetAllOrdersRequest>) => {
|
||||
// state
|
||||
|
||||
const { $axios: axios } = useNuxtApp();
|
||||
|
||||
// methods
|
||||
|
||||
const handleGetAllOrders = async (params: GetAllOrdersRequest) => {
|
||||
const { data } = await axios.get<GetAllOrdersResponse>(
|
||||
API_ENDPOINTS.orders.get_all,
|
||||
{
|
||||
params: {
|
||||
sort: params.sort,
|
||||
filter: params.status,
|
||||
offset: Number(params.page) * 7 - 7,
|
||||
limit: 7,
|
||||
},
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEYS.orders, params],
|
||||
queryFn: () => handleGetAllOrders(params.value),
|
||||
});
|
||||
};
|
||||
|
||||
export default useGetAllOrders;
|
||||
@@ -1,30 +0,0 @@
|
||||
// imports
|
||||
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
|
||||
|
||||
// types
|
||||
|
||||
export type GetOrdersAllResponse = Order[];
|
||||
|
||||
const useGetOrdersAll = () => {
|
||||
// state
|
||||
|
||||
const { $axios: axios } = useNuxtApp();
|
||||
|
||||
// methods
|
||||
|
||||
const handleGetOrdersAll = async () => {
|
||||
const { data } = await axios.get<GetOrdersAllResponse>(
|
||||
API_ENDPOINTS.orders.get_all
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEYS.orders],
|
||||
queryFn: () => handleGetOrdersAll(),
|
||||
});
|
||||
};
|
||||
|
||||
export default useGetOrdersAll;
|
||||
Reference in New Issue
Block a user