changed file name

This commit is contained in:
Mamalizz
2025-03-15 01:46:20 +03:30
parent 509afa2f04
commit d2abb83c31
2 changed files with 44 additions and 30 deletions
@@ -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;