@shopgate/engage
Version:
Shopgate's ENGAGE library.
37 lines (36 loc) • 1.1 kB
JavaScript
import React, { useCallback } from 'react';
import { RippleButton, I18n } from '@shopgate/engage/components';
import { button, ripple } from "./CartItemCardReservationLabelChangeStore.style";
import { useCartItem } from "../CartItem";
/**
* @returns {JSX}
*/
import { jsx as _jsx } from "react/jsx-runtime";
const CartItemCardReservationLabelChangeStore = () => {
const {
invokeFulfillmentAction,
cartItem
} = useCartItem();
const handleChangeLocationClick = useCallback(() => {
if (!cartItem || !cartItem.fulfillment || !cartItem.fulfillment.method) {
return;
}
const {
fulfillment: {
method
}
} = cartItem;
invokeFulfillmentAction('changeLocation', method);
}, [cartItem, invokeFulfillmentAction]);
return /*#__PURE__*/_jsx(RippleButton, {
onClick: handleChangeLocationClick,
className: button,
rippleClassName: ripple,
type: "secondary",
flat: true,
children: /*#__PURE__*/_jsx(I18n.Text, {
string: "locations.change_location"
})
});
};
export default CartItemCardReservationLabelChangeStore;