@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 1.26 kB
JavaScript
import*as React from'react';import{I18n,SurroundPortals,RippleButton}from'@shopgate/engage/components';import{CART_CHECKOUT_BUTTON}from'@shopgate/pwa-common-commerce/cart/constants/Portals';import{FulfillmentSheet,STAGE_RESERVE_FORM}from"../../../locations";import{CartContext}from"../../cart.context";import{button,disabledButton}from"./PaymentBarCheckoutButton.style";import connect from"./PaymentBarReserveButton.connector";/**
* The reserve button component.
* @param {Object} props The component props.
* @return {JSX}
*/function PaymentBarReserveButton(_ref){var historyReset=_ref.historyReset;var _React$useContext=React.useContext(CartContext),orderable=_React$useContext.flags.orderable;/**
* Handles the click on the button.
*/function handleClick(){FulfillmentSheet.open({stage:STAGE_RESERVE_FORM,callback:function callback(l,p,orderSuccess){if(orderSuccess===true){historyReset();}}});}return React.createElement(SurroundPortals,{portalName:CART_CHECKOUT_BUTTON,portalProps:{isActive:orderable}},React.createElement(RippleButton,{onClick:handleClick,disabled:!orderable,type:"regular",className:orderable?button:disabledButton},React.createElement(I18n.Text,{string:"cart.reserve"})));}export default connect(PaymentBarReserveButton);