@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.
@@ -52,8 +52,7 @@ var useInfiniteWooQuery = ({
52
52
  queryFn,
53
53
  params,
54
54
  perPage = 10,
55
- staleTime = StaleTimes.infinite,
56
- enabled
55
+ options
57
56
  }) => {
58
57
  const query = reactQuery.useInfiniteQuery({
59
58
  queryKey,
@@ -65,8 +64,8 @@ var useInfiniteWooQuery = ({
65
64
  initialPageParam: 1,
66
65
  getNextPageParam: (lastPage) => lastPage.pagination.nextPage,
67
66
  getPreviousPageParam: (firstPage) => firstPage.pagination.prevPage,
68
- staleTime,
69
- enabled
67
+ staleTime: StaleTimes.infinite,
68
+ ...options
70
69
  });
71
70
  const flatData = query.data?.pages.flatMap((page) => page.data) ?? [];
72
71
  return {
@@ -77,41 +76,45 @@ var useInfiniteWooQuery = ({
77
76
  };
78
77
 
79
78
  // src/hooks/products.ts
80
- var useProducts = (params) => {
79
+ var useProducts = (params, options) => {
81
80
  const client = useWooCommerceClient();
82
81
  const queryKeys = useWooCommerceQueryKeys();
83
82
  return reactQuery.useQuery({
84
83
  queryKey: queryKeys.products.list(params),
85
84
  queryFn: () => client.products.list(params),
86
- staleTime: StaleTimes.products
85
+ staleTime: StaleTimes.products,
86
+ ...options
87
87
  });
88
88
  };
89
- var useInfiniteProducts = (params) => {
89
+ var useInfiniteProducts = (params, options) => {
90
90
  const client = useWooCommerceClient();
91
91
  const queryKeys = useWooCommerceQueryKeys();
92
92
  return useInfiniteWooQuery({
93
93
  queryKey: queryKeys.products.list(params),
94
94
  queryFn: (p) => client.products.list({ ...p, page: p.page ?? 1 }),
95
95
  params,
96
- perPage: params?.per_page ?? 10
96
+ perPage: params?.per_page ?? 10,
97
+ options
97
98
  });
98
99
  };
99
- var useProduct = (id) => {
100
+ var useProduct = (id, options) => {
100
101
  const client = useWooCommerceClient();
101
102
  const queryKeys = useWooCommerceQueryKeys();
102
103
  return reactQuery.useQuery({
103
104
  queryKey: queryKeys.products.detail(id),
104
105
  queryFn: () => client.products.get(id),
105
- staleTime: StaleTimes.product
106
+ staleTime: StaleTimes.product,
107
+ ...options
106
108
  });
107
109
  };
108
- var useProductCategories = () => {
110
+ var useProductCategories = (options) => {
109
111
  const client = useWooCommerceClient();
110
112
  const queryKeys = useWooCommerceQueryKeys();
111
113
  return reactQuery.useQuery({
112
114
  queryKey: queryKeys.products.categories(),
113
115
  queryFn: () => client.products.categories(),
114
- staleTime: StaleTimes.categories
116
+ staleTime: StaleTimes.categories,
117
+ ...options
115
118
  });
116
119
  };
117
120
  var groupBy = (fn, list) => {
@@ -166,13 +169,14 @@ function createErrorEvent(type, error) {
166
169
  }
167
170
 
168
171
  // src/hooks/cart.ts
169
- var useCart = () => {
172
+ var useCart = (options) => {
170
173
  const client = useWooCommerceClient();
171
174
  const queryKeys = useWooCommerceQueryKeys();
172
175
  const query = reactQuery.useQuery({
173
176
  queryKey: queryKeys.cart.details(),
174
177
  queryFn: () => client.cart.get(),
175
- staleTime: StaleTimes.cart
178
+ staleTime: StaleTimes.cart,
179
+ ...options
176
180
  });
177
181
  const cart = query.data;
178
182
  const isInCart = (productId) => {
@@ -403,13 +407,14 @@ var useSelectShippingRate = () => {
403
407
  }
404
408
  });
405
409
  };
406
- var useCheckout = () => {
410
+ var useCheckout = (options) => {
407
411
  const client = useWooCommerceClient();
408
412
  const queryKeys = useWooCommerceQueryKeys();
409
413
  return reactQuery.useQuery({
410
414
  queryKey: queryKeys.checkout.details(),
411
415
  queryFn: () => client.checkout.get(),
412
- staleTime: StaleTimes.checkout
416
+ staleTime: StaleTimes.checkout,
417
+ ...options
413
418
  });
414
419
  };
415
420
  var useProcessCheckout = () => {
@@ -442,13 +447,14 @@ var useProcessCheckout = () => {
442
447
  }
443
448
  });
444
449
  };
445
- var useOrder = (input) => {
450
+ var useOrder = (input, options) => {
446
451
  const client = useWooCommerceClient();
447
452
  const queryKeys = useWooCommerceQueryKeys();
448
453
  return reactQuery.useQuery({
449
454
  queryKey: queryKeys.orders.detail(input.id, input.billing_email, input.key),
450
455
  queryFn: () => client.orders.get(input),
451
- staleTime: StaleTimes.orders
456
+ staleTime: StaleTimes.orders,
457
+ ...options
452
458
  });
453
459
  };
454
460