31 lines
625 B
TypeScript
31 lines
625 B
TypeScript
// imports
|
|
|
|
import { useQuery } from "@tanstack/vue-query";
|
|
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
|
|
|
|
// types
|
|
|
|
export type GetOrdersCartResponse = Order[];
|
|
|
|
const useGetOrdersCart = () => {
|
|
// state
|
|
|
|
const { $axios: axios } = useNuxtApp();
|
|
|
|
// methods
|
|
|
|
const handleGetOrdersCart = async () => {
|
|
const { data } = await axios.get<GetOrdersCartResponse>(
|
|
API_ENDPOINTS.orders.get_cart
|
|
);
|
|
return data;
|
|
};
|
|
|
|
return useQuery({
|
|
queryKey: [QUERY_KEYS.cart],
|
|
queryFn: () => handleGetOrdersCart(),
|
|
});
|
|
};
|
|
|
|
export default useGetOrdersCart;
|