@atomic-solutions/woocommerce-react 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -488,8 +488,7 @@ var useInfiniteWooQuery = ({
488
488
  queryFn,
489
489
  params,
490
490
  perPage = 10,
491
- staleTime = StaleTimes.infinite,
492
- enabled
491
+ options
493
492
  }) => {
494
493
  const query = reactQuery.useInfiniteQuery({
495
494
  queryKey,
@@ -501,8 +500,8 @@ var useInfiniteWooQuery = ({
501
500
  initialPageParam: 1,
502
501
  getNextPageParam: (lastPage) => lastPage.pagination.nextPage,
503
502
  getPreviousPageParam: (firstPage) => firstPage.pagination.prevPage,
504
- staleTime,
505
- enabled
503
+ staleTime: StaleTimes.infinite,
504
+ ...options
506
505
  });
507
506
  const flatData = query.data?.pages.flatMap((page) => page.data) ?? [];
508
507
  return {
@@ -513,41 +512,45 @@ var useInfiniteWooQuery = ({
513
512
  };
514
513
 
515
514
  // src/hooks/products.ts
516
- var useProducts = (params) => {
515
+ var useProducts = (params, options) => {
517
516
  const client = useWooCommerceClient();
518
517
  const queryKeys = useWooCommerceQueryKeys();
519
518
  return reactQuery.useQuery({
520
519
  queryKey: queryKeys.products.list(params),
521
520
  queryFn: () => client.products.list(params),
522
- staleTime: StaleTimes.products
521
+ staleTime: StaleTimes.products,
522
+ ...options
523
523
  });
524
524
  };
525
- var useInfiniteProducts = (params) => {
525
+ var useInfiniteProducts = (params, options) => {
526
526
  const client = useWooCommerceClient();
527
527
  const queryKeys = useWooCommerceQueryKeys();
528
528
  return useInfiniteWooQuery({
529
529
  queryKey: queryKeys.products.list(params),
530
530
  queryFn: (p) => client.products.list({ ...p, page: p.page ?? 1 }),
531
531
  params,
532
- perPage: params?.per_page ?? 10
532
+ perPage: params?.per_page ?? 10,
533
+ options
533
534
  });
534
535
  };
535
- var useProduct = (id) => {
536
+ var useProduct = (id, options) => {
536
537
  const client = useWooCommerceClient();
537
538
  const queryKeys = useWooCommerceQueryKeys();
538
539
  return reactQuery.useQuery({
539
540
  queryKey: queryKeys.products.detail(id),
540
541
  queryFn: () => client.products.get(id),
541
- staleTime: StaleTimes.product
542
+ staleTime: StaleTimes.product,
543
+ ...options
542
544
  });
543
545
  };
544
- var useProductCategories = () => {
546
+ var useProductCategories = (options) => {
545
547
  const client = useWooCommerceClient();
546
548
  const queryKeys = useWooCommerceQueryKeys();
547
549
  return reactQuery.useQuery({
548
550
  queryKey: queryKeys.products.categories(),
549
551
  queryFn: () => client.products.categories(),
550
- staleTime: StaleTimes.categories
552
+ staleTime: StaleTimes.categories,
553
+ ...options
551
554
  });
552
555
  };
553
556
  var groupBy = (fn, list) => {
@@ -598,13 +601,14 @@ function createErrorEvent(type, error) {
598
601
  }
599
602
 
600
603
  // src/hooks/cart.ts
601
- var useCart = () => {
604
+ var useCart = (options) => {
602
605
  const client = useWooCommerceClient();
603
606
  const queryKeys = useWooCommerceQueryKeys();
604
607
  const query = reactQuery.useQuery({
605
608
  queryKey: queryKeys.cart.details(),
606
609
  queryFn: () => client.cart.get(),
607
- staleTime: StaleTimes.cart
610
+ staleTime: StaleTimes.cart,
611
+ ...options
608
612
  });
609
613
  const cart = query.data;
610
614
  const isInCart = (productId) => {
@@ -835,13 +839,14 @@ var useSelectShippingRate = () => {
835
839
  }
836
840
  });
837
841
  };
838
- var useCheckout = () => {
842
+ var useCheckout = (options) => {
839
843
  const client = useWooCommerceClient();
840
844
  const queryKeys = useWooCommerceQueryKeys();
841
845
  return reactQuery.useQuery({
842
846
  queryKey: queryKeys.checkout.details(),
843
847
  queryFn: () => client.checkout.get(),
844
- staleTime: StaleTimes.checkout
848
+ staleTime: StaleTimes.checkout,
849
+ ...options
845
850
  });
846
851
  };
847
852
  var useProcessCheckout = () => {
@@ -874,13 +879,14 @@ var useProcessCheckout = () => {
874
879
  }
875
880
  });
876
881
  };
877
- var useOrder = (input) => {
882
+ var useOrder = (input, options) => {
878
883
  const client = useWooCommerceClient();
879
884
  const queryKeys = useWooCommerceQueryKeys();
880
885
  return reactQuery.useQuery({
881
886
  queryKey: queryKeys.orders.detail(input.id, input.billing_email, input.key),
882
887
  queryFn: () => client.orders.get(input),
883
- staleTime: StaleTimes.orders
888
+ staleTime: StaleTimes.orders,
889
+ ...options
884
890
  });
885
891
  };
886
892