Skip to content

Commit a46a997

Browse files
authored
bump (#21)
1 parent 91c9ac3 commit a46a997

File tree

10 files changed

+71
-38
lines changed

10 files changed

+71
-38
lines changed

blocks/product-details/product-details.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,33 @@ export default async function decorate(block) {
4747
slots: {
4848
Actions: (ctx) => {
4949
// Add to Cart Button
50-
ctx.appendButton((next) => ({
51-
text: 'Add to Cart',
52-
icon: 'Cart',
53-
variant: 'primary',
54-
onClick: async () => {
55-
try {
56-
if (!next.valid) {
50+
ctx.appendButton((next, state) => {
51+
const adding = state.get('adding');
52+
return {
53+
text: adding ? 'Adding to Cart' : 'Add to Cart',
54+
icon: 'Cart',
55+
variant: 'primary',
56+
disabled: adding || !next.data.inStock,
57+
onClick: async () => {
58+
try {
59+
state.set('adding', true);
60+
61+
if (!next.valid) {
62+
// eslint-disable-next-line no-console
63+
console.warn('Invalid product', next.values);
64+
return;
65+
}
66+
67+
await addProductsToCart([{ ...next.values }]);
68+
} catch (error) {
5769
// eslint-disable-next-line no-console
58-
console.warn('Invalid product', next.values);
59-
return;
70+
console.warn('Error adding product to cart', error);
71+
} finally {
72+
state.set('adding', false);
6073
}
61-
62-
await addProductsToCart([{ ...next.values }]);
63-
} catch (error) {
64-
// eslint-disable-next-line no-console
65-
console.warn('Error adding product to cart', error);
66-
}
67-
},
68-
}));
74+
},
75+
};
76+
});
6977

7078
// Add to Wishlist Button
7179
// ctx.appendButton(() => ({

package-lock.json

Lines changed: 38 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@dropins/storefront-cart": "0.1.0-alpha12",
3939
"@dropins/storefront-checkout": "0.1.0-alpha23",
4040
"@dropins/storefront-order-confirmation": "0.1.0-alpha14",
41-
"@dropins/storefront-pdp": "^0.2.2-alpha12",
42-
"@dropins/tools": "latest"
41+
"@dropins/storefront-pdp": "0.2.2-alpha14",
42+
"@dropins/tools": "0.18.0"
4343
}
4444
}

scripts/__dropins__/storefront-pdp/396.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/__dropins__/storefront-pdp/606.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/__dropins__/storefront-pdp/713.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/__dropins__/storefront-pdp/997.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

scripts/__dropins__/storefront-pdp/containers/ProductDetails.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/__dropins__/storefront-pdp/runtime.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)