@atomic-solutions/woocommerce-react 0.2.6 → 0.3.1
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 +50 -0
- 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 +49 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-CaNfLsEj.d.cts → index-DdY_1X-C.d.cts} +32 -1
- package/dist/{index-BWIYt7TO.d.ts → index-unbfwba0.d.ts} +32 -1
- package/dist/index.cjs +50 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -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,
|
|
1
|
+
export { A as AppliedCoupon, C as CartTotals, a2 as InfiniteQueryOptions, a3 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, a4 as QueryOptions, S as ShippingRate, U as UseCartViewOptions, j as UseCartViewReturn, k as UseOrderViewOptions, l as UseOrderViewReturn, m as UseProductViewOptions, n as UseProductViewReturn, o as UseProductsFeedOptions, p as UseProductsFeedReturn, t as getOrderStatusLabel, y as useAddToCart, z as useApplyCoupon, B as useCart, D as useCartView, E as useCheckout, F as useInfiniteProducts, G as useOrder, H as useOrderView, J as useProcessCheckout, K as useProduct, L as useProductCategories, M as useProductCategoryTree, N as useProductView, O as useProducts, Q as useProductsFeed, R as useRemoveCoupon, T as useRemoveFromCart, V as useSelectShippingRate, W as useStore, X as useStoreFeatures, Y as useStoreLocale, Z as useStoreTheme, _ as useUpdateCartItem, $ as useUpdateCustomer, a0 as useWooCommerceClient, a1 as useWooCommerceQueryKeys } from '../index-DdY_1X-C.cjs';
|
|
2
2
|
export { Q as QueryKeys, p as createQueryKeys } from '../types-_8YqnkO-.cjs';
|
|
3
|
+
export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
|
|
3
4
|
import '@tanstack/react-query';
|
|
4
|
-
import '@atomic-solutions/woocommerce-api-client';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppliedCoupon, C as CartTotals,
|
|
1
|
+
export { A as AppliedCoupon, C as CartTotals, a2 as InfiniteQueryOptions, a3 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, a4 as QueryOptions, S as ShippingRate, U as UseCartViewOptions, j as UseCartViewReturn, k as UseOrderViewOptions, l as UseOrderViewReturn, m as UseProductViewOptions, n as UseProductViewReturn, o as UseProductsFeedOptions, p as UseProductsFeedReturn, t as getOrderStatusLabel, y as useAddToCart, z as useApplyCoupon, B as useCart, D as useCartView, E as useCheckout, F as useInfiniteProducts, G as useOrder, H as useOrderView, J as useProcessCheckout, K as useProduct, L as useProductCategories, M as useProductCategoryTree, N as useProductView, O as useProducts, Q as useProductsFeed, R as useRemoveCoupon, T as useRemoveFromCart, V as useSelectShippingRate, W as useStore, X as useStoreFeatures, Y as useStoreLocale, Z as useStoreTheme, _ as useUpdateCartItem, $ as useUpdateCustomer, a0 as useWooCommerceClient, a1 as useWooCommerceQueryKeys } from '../index-unbfwba0.js';
|
|
2
2
|
export { Q as QueryKeys, p as createQueryKeys } from '../types-_8YqnkO-.js';
|
|
3
|
+
export { OrderStatus } from '@atomic-solutions/woocommerce-api-client';
|
|
3
4
|
import '@tanstack/react-query';
|
|
4
|
-
import '@atomic-solutions/woocommerce-api-client';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1133,7 +1133,55 @@ function useCartView(options = {}) {
|
|
|
1133
1133
|
isBusy
|
|
1134
1134
|
};
|
|
1135
1135
|
}
|
|
1136
|
+
var ORDER_STATUS_LABELS = {
|
|
1137
|
+
pending: "Pending Payment",
|
|
1138
|
+
processing: "Processing",
|
|
1139
|
+
"on-hold": "On Hold",
|
|
1140
|
+
completed: "Completed",
|
|
1141
|
+
cancelled: "Cancelled",
|
|
1142
|
+
refunded: "Refunded",
|
|
1143
|
+
failed: "Failed"
|
|
1144
|
+
};
|
|
1145
|
+
function getOrderStatusLabel(status) {
|
|
1146
|
+
return ORDER_STATUS_LABELS[status] ?? status.replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
1147
|
+
}
|
|
1148
|
+
function useOrderView(input, options = {}) {
|
|
1149
|
+
const storeContext = useContext(WooCommerceStoreContext);
|
|
1150
|
+
const storeConfig = storeContext?.config;
|
|
1151
|
+
const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
|
|
1152
|
+
const { data: rawOrder, isLoading, error } = useOrder(input);
|
|
1153
|
+
const order = useMemo(() => {
|
|
1154
|
+
if (!rawOrder) return void 0;
|
|
1155
|
+
const currencyCode = rawOrder.totals.currency_code ?? "USD";
|
|
1156
|
+
const lineItems = rawOrder.items.map((item) => ({
|
|
1157
|
+
id: item.id,
|
|
1158
|
+
name: item.name,
|
|
1159
|
+
quantity: item.quantity,
|
|
1160
|
+
price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
|
|
1161
|
+
total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
|
|
1162
|
+
imageUrl: item.images?.[0]?.src
|
|
1163
|
+
}));
|
|
1164
|
+
const status = rawOrder.status;
|
|
1165
|
+
return {
|
|
1166
|
+
id: rawOrder.id,
|
|
1167
|
+
number: String(rawOrder.id),
|
|
1168
|
+
status,
|
|
1169
|
+
statusLabel: getOrderStatusLabel(status),
|
|
1170
|
+
total: formatStoreApiPriceIntl(rawOrder.totals.total_price, currencyCode, localeTag),
|
|
1171
|
+
itemCount: lineItems.reduce((sum, item) => sum + item.quantity, 0),
|
|
1172
|
+
lineItems,
|
|
1173
|
+
needsPayment: rawOrder.needs_payment,
|
|
1174
|
+
paymentMethod: rawOrder.payment_method ?? "",
|
|
1175
|
+
raw: rawOrder
|
|
1176
|
+
};
|
|
1177
|
+
}, [rawOrder, localeTag]);
|
|
1178
|
+
return {
|
|
1179
|
+
order,
|
|
1180
|
+
isLoading,
|
|
1181
|
+
error
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1136
1184
|
|
|
1137
|
-
export { createQueryKeys, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys };
|
|
1185
|
+
export { createQueryKeys, getOrderStatusLabel, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useOrderView, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys };
|
|
1138
1186
|
//# sourceMappingURL=index.js.map
|
|
1139
1187
|
//# sourceMappingURL=index.js.map
|