Skip to content

Commit

Permalink
update 1.1.0 (#3)
Browse files Browse the repository at this point in the history
1.1.0 (compatibility with venia 12)
  • Loading branch information
edlay17 authored Nov 29, 2021
1 parent 45acd89 commit a7900d1
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ MiniCartProductListingGql_GiftCard.insertAfterSource(
);
const ProductListingGql_GiftCard = giftCardsTargetables.module(
'@magento/venia-ui/lib/components/CartPage/ProductListing/productListingFragments.js'
'@magento/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js'
);
ProductListingGql_GiftCard.insertAfterSource(
'items {\n',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mageworx/giftcards-veniapwa",
"author": "mageworx",
"version": "1.0.0",
"version": "1.1.0",
"homepage": "https://www.mageworx.com/magento-2-gift-cards.html",
"repository": {
"type": "git",
Expand All @@ -21,9 +21,9 @@
}
},
"peerDependencies": {
"@magento/peregrine": "^11.0.0",
"@magento/pwa-buildpack": ">=10.0.0",
"@magento/venia-ui": "^8.0.0"
"@magento/peregrine": "^12.0.0",
"@magento/pwa-buildpack": ">=11.0.0",
"@magento/venia-ui": "^9.0.0"
},
"dependencies": {
"react-datepicker": "^4.2.1"
Expand Down
2 changes: 1 addition & 1 deletion src/UI/templates/GiftCardDetail/giftCardDetail.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.giftCardOptionsTitle {
composes: title from '~@magento/venia-ui/lib/components/ProductOptions/option.css';
composes: title from '~@magento/venia-ui/lib/components/ProductOptions/option.module.css';
}
4 changes: 2 additions & 2 deletions src/documentation/local-intercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function localIntercept(targets) {
);

const ProductListingGql_GiftCard = giftCardsTargetables.module(
'@magento/venia-ui/lib/components/CartPage/ProductListing/productListingFragments.js'
'@magento/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js'
);
ProductListingGql_GiftCard.insertAfterSource(
'items {\n',
Expand All @@ -109,4 +109,4 @@ function localIntercept(targets) {
/* MageWorx giftcards-veniapwa end */
}

module.exports = localIntercept;
module.exports = localIntercept;
32 changes: 32 additions & 0 deletions src/features/Category/modify/targets/wrapUseAddToCartButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {useHistory} from "react-router-dom";
import {useCallback} from "react";

const wrapUseAddToCartButton = (original) => {
return function useAddToCartButton (props, ...restArgs) {
const { ...defaultReturnData } = original(
props,
...restArgs
);

const { item } = props;
const isInStock = item.stock_status === 'IN_STOCK';
const productType = item.type_id;
const history = useHistory();

const handleAddToCart = useCallback(() => {
history.push(`${item.url_key}.html`);
}, [history, item.url_key]);

if (productType !== "mageworx_giftcards") {
return defaultReturnData;
}

return {
...defaultReturnData,
isDisabled: !isInStock,
handleAddToCart
};
};
};

export default wrapUseAddToCartButton;
19 changes: 19 additions & 0 deletions src/features/Category/modify/targets/wrapUseGalleryItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const wrapUseGalleryItem = (original) => {
return function useGalleryItem (props, ...restArgs) {
const { ...defaultReturnData } = original(
props,
...restArgs
);

const { item } = props;
const productType = item ? item.__typename : null;
const isSupportedProductType = defaultReturnData.isSupportedProductType || productType === "MageWorxGiftCards";

return {
...defaultReturnData,
isSupportedProductType
};
};
};

export default wrapUseGalleryItem;
12 changes: 12 additions & 0 deletions src/intercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ module.exports = targets => {
"@mageworx/giftcards-veniapwa/src/features/Cart/modify/targets/wrapUsePriceSummary"
);
});

// category
talonsTarget.tap((talonWrapperConfig) => {
talonWrapperConfig.Gallery.useAddToCartButton.wrapWith(
"@mageworx/giftcards-veniapwa/src/features/Category/modify/targets/wrapUseAddToCartButton"
);
});
talonsTarget.tap((talonWrapperConfig) => {
talonWrapperConfig.Gallery.useGalleryItem.wrapWith(
"@mageworx/giftcards-veniapwa/src/features/Category/modify/targets/wrapUseGalleryItem"
);
});
};

0 comments on commit a7900d1

Please sign in to comment.