31 lines
620 B
TypeScript
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;
|