@atomic-solutions/woocommerce-react 0.6.2 → 0.8.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/hooks/index.cjs +35 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +34 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-Dmlapl9c.d.ts → index-C6OkRa8P.d.ts} +202 -5
- package/dist/{index-DEvJWFSF.d.cts → index-DtuDPfTl.d.cts} +202 -5
- package/dist/index.cjs +35 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.cts +2 -2
- package/dist/provider/index.d.ts +2 -2
- package/dist/{types-Dnq60zh-.d.cts → types-DABmdACe.d.cts} +3 -1
- package/dist/{types-Dnq60zh-.d.ts → types-DABmdACe.d.ts} +3 -1
- package/package.json +2 -2
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppliedCoupon, C as CartTotals,
|
|
2
|
-
export { Q as QueryKeys, p as createQueryKeys } from '../types-
|
|
1
|
+
export { A as AppliedCoupon, C as CartTotals, al as InfiniteQueryOptions, am as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, an as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, E as getOrderStatusLabel, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductTags, a5 as useProductView, a6 as useProducts, a7 as useProductsFeed, a8 as useRemoveCoupon, a9 as useRemoveFromCart, aa as useReorderView, ab as useSelectShippingRate, ac as useStore, ad as useStoreFeatures, ae as useStoreLocale, af as useStoreTheme, ag as useUpdateCartExtensions, ah as useUpdateCartItem, ai as useUpdateCustomer, aj as useWooCommerceClient, ak as useWooCommerceQueryKeys } from '../index-DtuDPfTl.cjs';
|
|
2
|
+
export { Q as QueryKeys, p as createQueryKeys } from '../types-DABmdACe.cjs';
|
|
3
3
|
export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
|
|
4
4
|
import '@tanstack/react-query';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppliedCoupon, C as CartTotals,
|
|
2
|
-
export { Q as QueryKeys, p as createQueryKeys } from '../types-
|
|
1
|
+
export { A as AppliedCoupon, C as CartTotals, al as InfiniteQueryOptions, am as MutationOptions, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedOrderDetails, e as ProcessedOrderLineItem, f as ProcessedProduct, g as ProcessedProductDetails, h as ProductCartState, i as ProductCategoryTreeNode, an as QueryOptions, R as ReorderInputItem, j as ReorderItemView, k as ReorderUnavailableReason, S as ShippingRate, n as UseCartViewOptions, o as UseCartViewReturn, p as UseOrderViewOptions, q as UseOrderViewReturn, r as UseProductViewOptions, s as UseProductViewReturn, t as UseProductsFeedOptions, u as UseProductsFeedReturn, v as UseReorderViewOptions, w as UseReorderViewReturn, E as getOrderStatusLabel, Q as useAddManyToCart, T as useAddToCart, V as useApplyCoupon, W as useCart, X as useCartView, Y as useCheckout, Z as useInfiniteProducts, _ as useOrder, $ as useOrderView, a0 as useProcessCheckout, a1 as useProduct, a2 as useProductCategories, a3 as useProductCategoryTree, a4 as useProductTags, a5 as useProductView, a6 as useProducts, a7 as useProductsFeed, a8 as useRemoveCoupon, a9 as useRemoveFromCart, aa as useReorderView, ab as useSelectShippingRate, ac as useStore, ad as useStoreFeatures, ae as useStoreLocale, af as useStoreTheme, ag as useUpdateCartExtensions, ah as useUpdateCartItem, ai as useUpdateCustomer, aj as useWooCommerceClient, ak as useWooCommerceQueryKeys } from '../index-C6OkRa8P.js';
|
|
2
|
+
export { Q as QueryKeys, p as createQueryKeys } from '../types-DABmdACe.js';
|
|
3
3
|
export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
|
|
4
4
|
import '@tanstack/react-query';
|
package/dist/hooks/index.js
CHANGED
|
@@ -40,6 +40,8 @@ var StaleTimes = {
|
|
|
40
40
|
product: STALE_TIME_SHORT,
|
|
41
41
|
/** Product categories - always fresh */
|
|
42
42
|
categories: STALE_TIME_NONE,
|
|
43
|
+
/** Product tags - names rarely change, 1 hour */
|
|
44
|
+
tags: STALE_TIME_LONG,
|
|
43
45
|
/** Orders - always fresh */
|
|
44
46
|
orders: STALE_TIME_NONE,
|
|
45
47
|
/** Default for infinite queries - 1 hour */
|
|
@@ -137,6 +139,16 @@ var processCategoriesToTree = (data) => {
|
|
|
137
139
|
});
|
|
138
140
|
return rootCategories?.map(processCategory) ?? [];
|
|
139
141
|
};
|
|
142
|
+
var useProductTags = (params, options) => {
|
|
143
|
+
const client = useWooCommerceClient();
|
|
144
|
+
const queryKeys = useWooCommerceQueryKeys();
|
|
145
|
+
return useQuery({
|
|
146
|
+
queryKey: queryKeys.products.tags(params),
|
|
147
|
+
queryFn: () => client.products.tags(params),
|
|
148
|
+
staleTime: StaleTimes.tags,
|
|
149
|
+
...options
|
|
150
|
+
});
|
|
151
|
+
};
|
|
140
152
|
var useProductCategoryTree = () => {
|
|
141
153
|
const query = useProductCategories();
|
|
142
154
|
const flatData = query.data ?? [];
|
|
@@ -355,6 +367,19 @@ var useRemoveCoupon = () => {
|
|
|
355
367
|
}
|
|
356
368
|
});
|
|
357
369
|
};
|
|
370
|
+
var useUpdateCartExtensions = () => {
|
|
371
|
+
const client = useWooCommerceClient();
|
|
372
|
+
const queryKeys = useWooCommerceQueryKeys();
|
|
373
|
+
const queryClient = useQueryClient();
|
|
374
|
+
return useMutation({
|
|
375
|
+
mutationKey: queryKeys.cart.mutations.updateExtensions(),
|
|
376
|
+
mutationFn: (input) => client.cart.updateExtensions(input),
|
|
377
|
+
onSuccess: (cart) => {
|
|
378
|
+
queryClient.setQueryData(queryKeys.cart.details(), cart);
|
|
379
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.cart.all });
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
};
|
|
358
383
|
var useUpdateCustomer = () => {
|
|
359
384
|
const client = useWooCommerceClient();
|
|
360
385
|
const queryKeys = useWooCommerceQueryKeys();
|
|
@@ -461,7 +486,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
|
|
|
461
486
|
list: (params) => [...prefix, "products", "list", params],
|
|
462
487
|
details: () => [...prefix, "products", "detail"],
|
|
463
488
|
detail: (id) => [...prefix, "products", "detail", id],
|
|
464
|
-
categories: () => [...prefix, "products", "categories"]
|
|
489
|
+
categories: () => [...prefix, "products", "categories"],
|
|
490
|
+
// Params are in the key, so each set of tag ids is cached apart.
|
|
491
|
+
tags: (params) => [...prefix, "products", "tags", params]
|
|
465
492
|
},
|
|
466
493
|
// Cart
|
|
467
494
|
cart: {
|
|
@@ -475,6 +502,7 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
|
|
|
475
502
|
removeItem: () => [...prefix, "cart", "mutation", "removeItem"],
|
|
476
503
|
applyCoupon: () => [...prefix, "cart", "mutation", "applyCoupon"],
|
|
477
504
|
removeCoupon: () => [...prefix, "cart", "mutation", "removeCoupon"],
|
|
505
|
+
updateExtensions: () => [...prefix, "cart", "mutation", "updateExtensions"],
|
|
478
506
|
updateCustomer: () => [...prefix, "cart", "mutation", "updateCustomer"],
|
|
479
507
|
selectShippingRate: () => [...prefix, "cart", "mutation", "selectShippingRate"]
|
|
480
508
|
}
|
|
@@ -1222,6 +1250,8 @@ function useOrderView(input, options = {}) {
|
|
|
1222
1250
|
const storeContext = useContext(WooCommerceStoreContext);
|
|
1223
1251
|
const storeConfig = storeContext?.config;
|
|
1224
1252
|
const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
|
|
1253
|
+
const { imageSize = "thumbnail" } = options;
|
|
1254
|
+
const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
|
|
1225
1255
|
const { data: rawOrder, isLoading, error } = useOrder(input);
|
|
1226
1256
|
const order = useMemo(() => {
|
|
1227
1257
|
if (!rawOrder) return void 0;
|
|
@@ -1232,7 +1262,7 @@ function useOrderView(input, options = {}) {
|
|
|
1232
1262
|
quantity: item.quantity,
|
|
1233
1263
|
price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
|
|
1234
1264
|
total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
|
|
1235
|
-
imageUrl: item.images
|
|
1265
|
+
imageUrl: getProcessedImageUrl(item.images)
|
|
1236
1266
|
}));
|
|
1237
1267
|
const status = rawOrder.status;
|
|
1238
1268
|
return {
|
|
@@ -1247,7 +1277,7 @@ function useOrderView(input, options = {}) {
|
|
|
1247
1277
|
paymentMethod: rawOrder.payment_method ?? "",
|
|
1248
1278
|
raw: rawOrder
|
|
1249
1279
|
};
|
|
1250
|
-
}, [rawOrder, localeTag]);
|
|
1280
|
+
}, [rawOrder, localeTag, getProcessedImageUrl]);
|
|
1251
1281
|
return {
|
|
1252
1282
|
order,
|
|
1253
1283
|
isLoading,
|
|
@@ -1255,6 +1285,6 @@ function useOrderView(input, options = {}) {
|
|
|
1255
1285
|
};
|
|
1256
1286
|
}
|
|
1257
1287
|
|
|
1258
|
-
export { createQueryKeys, getOrderStatusLabel, useAddManyToCart, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useOrderView, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useReorderView, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys };
|
|
1288
|
+
export { createQueryKeys, getOrderStatusLabel, useAddManyToCart, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useOrderView, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductTags, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useReorderView, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartExtensions, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys };
|
|
1259
1289
|
//# sourceMappingURL=index.js.map
|
|
1260
1290
|
//# sourceMappingURL=index.js.map
|