Files
hossein-por-shop/frontend/composables/api/orders/useGetOrdersAll.ts
T
2025-03-09 20:39:23 +03:30

31 lines
620 B
TypeScript

// 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;