@wix/headless-stores 0.0.39 → 0.0.40
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/cjs/dist/react/ProductListFilters.d.ts +5 -5
- package/cjs/dist/react/ProductListFilters.js +5 -5
- package/cjs/dist/react/ProductListPagination.d.ts +3 -3
- package/cjs/dist/react/ProductListPagination.js +4 -4
- package/cjs/dist/react/ProductListSort.d.ts +5 -5
- package/cjs/dist/react/ProductListSort.js +6 -6
- package/cjs/dist/react/ProductModifiers.d.ts +11 -11
- package/cjs/dist/react/ProductModifiers.js +14 -14
- package/cjs/dist/react/ProductVariantSelector.d.ts +7 -11
- package/cjs/dist/react/ProductVariantSelector.js +8 -10
- package/cjs/dist/react/SelectedVariant.d.ts +6 -6
- package/cjs/dist/react/SelectedVariant.js +8 -8
- package/cjs/dist/services/products-list-pagination-service.d.ts +5 -5
- package/cjs/dist/services/products-list-pagination-service.js +2 -2
- package/cjs/dist/services/products-list-service.d.ts +4 -2
- package/cjs/dist/services/products-list-service.js +4 -2
- package/dist/react/ProductListFilters.d.ts +5 -5
- package/dist/react/ProductListFilters.js +5 -5
- package/dist/react/ProductListPagination.d.ts +3 -3
- package/dist/react/ProductListPagination.js +4 -4
- package/dist/react/ProductListSort.d.ts +5 -5
- package/dist/react/ProductListSort.js +6 -6
- package/dist/react/ProductModifiers.d.ts +11 -11
- package/dist/react/ProductModifiers.js +14 -14
- package/dist/react/ProductVariantSelector.d.ts +7 -11
- package/dist/react/ProductVariantSelector.js +8 -10
- package/dist/react/SelectedVariant.d.ts +6 -6
- package/dist/react/SelectedVariant.js +8 -8
- package/dist/services/products-list-pagination-service.d.ts +5 -5
- package/dist/services/products-list-pagination-service.js +2 -2
- package/dist/services/products-list-service.d.ts +4 -2
- package/dist/services/products-list-service.js +4 -2
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SelectedVariantServiceConfig } from "../services/selected-variant-service.js";
|
|
2
2
|
export interface RootProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
selectedVariantServiceConfig
|
|
4
|
+
selectedVariantServiceConfig?: SelectedVariantServiceConfig;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Root component that provides the SelectedVariant service context to its children.
|
|
@@ -174,9 +174,9 @@ export interface ActionsProps {
|
|
|
174
174
|
*/
|
|
175
175
|
export interface ActionsRenderProps {
|
|
176
176
|
/** Function to add product to cart */
|
|
177
|
-
|
|
177
|
+
addToCart: () => Promise<void>;
|
|
178
178
|
/** Function to buy now (clear cart, add product, proceed to checkout) */
|
|
179
|
-
|
|
179
|
+
buyNow: () => Promise<void>;
|
|
180
180
|
/** Whether add to cart is available */
|
|
181
181
|
canAddToCart: boolean;
|
|
182
182
|
/** Whether add to cart is currently loading */
|
|
@@ -201,18 +201,18 @@ export interface ActionsRenderProps {
|
|
|
201
201
|
* function AddToCartButton() {
|
|
202
202
|
* return (
|
|
203
203
|
* <SelectedVariant.Actions>
|
|
204
|
-
* {({
|
|
204
|
+
* {({ addToCart, buyNow, canAddToCart, isLoading, inStock, error }) => (
|
|
205
205
|
* <div>
|
|
206
206
|
* {error && <div className="error">{error}</div>}
|
|
207
207
|
* {!inStock && <div>Out of stock</div>}
|
|
208
208
|
* <button
|
|
209
|
-
* onClick={
|
|
209
|
+
* onClick={addToCart}
|
|
210
210
|
* disabled={!canAddToCart || isLoading}
|
|
211
211
|
* >
|
|
212
212
|
* {isLoading ? 'Adding...' : 'Add to Cart'}
|
|
213
213
|
* </button>
|
|
214
214
|
* <button
|
|
215
|
-
* onClick={
|
|
215
|
+
* onClick={buyNow}
|
|
216
216
|
* disabled={!canAddToCart || isLoading}
|
|
217
217
|
* >
|
|
218
218
|
* Buy Now
|
|
@@ -154,18 +154,18 @@ export function SKU(props) {
|
|
|
154
154
|
* function AddToCartButton() {
|
|
155
155
|
* return (
|
|
156
156
|
* <SelectedVariant.Actions>
|
|
157
|
-
* {({
|
|
157
|
+
* {({ addToCart, buyNow, canAddToCart, isLoading, inStock, error }) => (
|
|
158
158
|
* <div>
|
|
159
159
|
* {error && <div className="error">{error}</div>}
|
|
160
160
|
* {!inStock && <div>Out of stock</div>}
|
|
161
161
|
* <button
|
|
162
|
-
* onClick={
|
|
162
|
+
* onClick={addToCart}
|
|
163
163
|
* disabled={!canAddToCart || isLoading}
|
|
164
164
|
* >
|
|
165
165
|
* {isLoading ? 'Adding...' : 'Add to Cart'}
|
|
166
166
|
* </button>
|
|
167
167
|
* <button
|
|
168
|
-
* onClick={
|
|
168
|
+
* onClick={buyNow}
|
|
169
169
|
* disabled={!canAddToCart || isLoading}
|
|
170
170
|
* >
|
|
171
171
|
* Buy Now
|
|
@@ -202,7 +202,7 @@ export function Actions(props) {
|
|
|
202
202
|
const canAddToCart = (inStock || isPreOrderEnabled) &&
|
|
203
203
|
!isLoading &&
|
|
204
204
|
areAllRequiredModifiersFilled;
|
|
205
|
-
const
|
|
205
|
+
const addToCart = async () => {
|
|
206
206
|
// Get modifiers data if available
|
|
207
207
|
let modifiersData;
|
|
208
208
|
if (modifiersService) {
|
|
@@ -213,12 +213,12 @@ export function Actions(props) {
|
|
|
213
213
|
}
|
|
214
214
|
await variantService.addToCart(quantity, modifiersData);
|
|
215
215
|
};
|
|
216
|
-
const
|
|
216
|
+
const buyNow = async () => {
|
|
217
217
|
try {
|
|
218
218
|
// Clear the cart first
|
|
219
219
|
await cartService.clearCart();
|
|
220
220
|
// Add the product to cart
|
|
221
|
-
await
|
|
221
|
+
await addToCart();
|
|
222
222
|
// Proceed to checkout
|
|
223
223
|
await cartService.proceedToCheckout();
|
|
224
224
|
}
|
|
@@ -228,8 +228,8 @@ export function Actions(props) {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
return props.children({
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
addToCart,
|
|
232
|
+
buyNow,
|
|
233
233
|
canAddToCart,
|
|
234
234
|
isLoading,
|
|
235
235
|
inStock,
|
|
@@ -26,7 +26,7 @@ export declare const ProductsListPaginationServiceDefinition: string & {
|
|
|
26
26
|
/** Function to navigate to the previous page */
|
|
27
27
|
prevPage: () => void;
|
|
28
28
|
/** Function to navigate to the first page */
|
|
29
|
-
|
|
29
|
+
navigateToFirstPage: () => void;
|
|
30
30
|
/** Function to load more items (increase the limit) */
|
|
31
31
|
loadMore: (count: number) => void;
|
|
32
32
|
};
|
|
@@ -52,7 +52,7 @@ export declare const ProductsListPaginationServiceDefinition: string & {
|
|
|
52
52
|
/** Function to navigate to the previous page */
|
|
53
53
|
prevPage: () => void;
|
|
54
54
|
/** Function to navigate to the first page */
|
|
55
|
-
|
|
55
|
+
navigateToFirstPage: () => void;
|
|
56
56
|
/** Function to load more items (increase the limit) */
|
|
57
57
|
loadMore: (count: number) => void;
|
|
58
58
|
};
|
|
@@ -106,7 +106,7 @@ export type ProductsListPaginationServiceConfig = {};
|
|
|
106
106
|
*
|
|
107
107
|
* <div>
|
|
108
108
|
* <button
|
|
109
|
-
* onClick={() => paginationService.
|
|
109
|
+
* onClick={() => paginationService.navigateToFirstPage()}
|
|
110
110
|
* disabled={!hasPrevPage}
|
|
111
111
|
* >
|
|
112
112
|
* First
|
|
@@ -154,7 +154,7 @@ export declare const ProductsListPaginationService: import("@wix/services-defini
|
|
|
154
154
|
/** Function to navigate to the previous page */
|
|
155
155
|
prevPage: () => void;
|
|
156
156
|
/** Function to navigate to the first page */
|
|
157
|
-
|
|
157
|
+
navigateToFirstPage: () => void;
|
|
158
158
|
/** Function to load more items (increase the limit) */
|
|
159
159
|
loadMore: (count: number) => void;
|
|
160
160
|
};
|
|
@@ -180,7 +180,7 @@ export declare const ProductsListPaginationService: import("@wix/services-defini
|
|
|
180
180
|
/** Function to navigate to the previous page */
|
|
181
181
|
prevPage: () => void;
|
|
182
182
|
/** Function to navigate to the first page */
|
|
183
|
-
|
|
183
|
+
navigateToFirstPage: () => void;
|
|
184
184
|
/** Function to load more items (increase the limit) */
|
|
185
185
|
loadMore: (count: number) => void;
|
|
186
186
|
}, ProductsListPaginationServiceConfig>;
|
|
@@ -52,7 +52,7 @@ export const ProductsListPaginationServiceDefinition = defineService("products-l
|
|
|
52
52
|
*
|
|
53
53
|
* <div>
|
|
54
54
|
* <button
|
|
55
|
-
* onClick={() => paginationService.
|
|
55
|
+
* onClick={() => paginationService.navigateToFirstPage()}
|
|
56
56
|
* disabled={!hasPrevPage}
|
|
57
57
|
* >
|
|
58
58
|
* First
|
|
@@ -150,7 +150,7 @@ export const ProductsListPaginationService = implementService.withConfig()(Produ
|
|
|
150
150
|
currentCursorSignal.set(previousCursor);
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
|
-
|
|
153
|
+
navigateToFirstPage: () => {
|
|
154
154
|
currentCursorSignal.set(null);
|
|
155
155
|
},
|
|
156
156
|
};
|
|
@@ -68,8 +68,10 @@ export type ProductsListServiceConfig = {
|
|
|
68
68
|
* export const getServerSideProps: GetServerSideProps<ProductsPageProps> = async () => {
|
|
69
69
|
* const searchOptions = {
|
|
70
70
|
* cursorPaging: { limit: 12 },
|
|
71
|
-
* filter: {
|
|
72
|
-
*
|
|
71
|
+
* filter: {
|
|
72
|
+
* 'allCategoriesInfo.categories': { $matchItems: [{ _id: { $in: [category._id] } }] }
|
|
73
|
+
* },
|
|
74
|
+
* sort: [{ fieldName: 'name' as const, order: 'ASC' as const }]
|
|
73
75
|
* };
|
|
74
76
|
*
|
|
75
77
|
* const productsConfig = await loadProductsListServiceConfig(searchOptions);
|
|
@@ -53,8 +53,10 @@ import { productsV3, readOnlyVariantsV3 } from "@wix/stores";
|
|
|
53
53
|
* export const getServerSideProps: GetServerSideProps<ProductsPageProps> = async () => {
|
|
54
54
|
* const searchOptions = {
|
|
55
55
|
* cursorPaging: { limit: 12 },
|
|
56
|
-
* filter: {
|
|
57
|
-
*
|
|
56
|
+
* filter: {
|
|
57
|
+
* 'allCategoriesInfo.categories': { $matchItems: [{ _id: { $in: [category._id] } }] }
|
|
58
|
+
* },
|
|
59
|
+
* sort: [{ fieldName: 'name' as const, order: 'ASC' as const }]
|
|
58
60
|
* };
|
|
59
61
|
*
|
|
60
62
|
* const productsConfig = await loadProductsListServiceConfig(searchOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/headless-stores",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "cd ../media && yarn build && cd ../ecom && yarn build",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@wix/ecom": "^1.0.1238",
|
|
60
60
|
"@wix/essentials": "^0.1.24",
|
|
61
61
|
"@wix/headless-ecom": "^0.0.11",
|
|
62
|
-
"@wix/headless-media": "^0.0.
|
|
62
|
+
"@wix/headless-media": "^0.0.8",
|
|
63
63
|
"@wix/redirects": "^1.0.83",
|
|
64
64
|
"@wix/services-definitions": "^0.1.4",
|
|
65
65
|
"@wix/services-manager-react": "^0.1.26"
|