import { useQuery } from "@tanstack/react-query";
import * as api from "../service/OrderService";

export const useGetNativeOrders = (
  page: number = 1,
  status: string = "all"
) => {
  const { data, isLoading, error } = useQuery({
    queryKey: ["orders", page, status],
    queryFn: () => api.getNativeOrders(page, status),
  });
  return { data, isLoading, error };
};

export const useGetSellerOrders = (
  page: number = 1,
  status: string = "all"
) => {
  const { data, isLoading, error } = useQuery({
    queryKey: ["orders", page, status],
    queryFn: () => api.getSellerOrders(page, status),
  });
  return { data, isLoading, error };
};

export const useGetOrderDetailUser = (id: string) => {
  return useQuery({
    queryKey: ["order-detail-user", id],
    queryFn: () => api.getOrderDetailUser(id),
    enabled: !!id,
  });
};
