UNPKG

@shopgate/engage

Version:
5 lines 1.92 kB
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import*as React from'react';import classNames from'classnames';import{Grid}from'@shopgate/engage/components';import{i18n}from"../../../core";import{Availability}from"../../../product";import{DIRECT_SHIP_LABEL,DIRECT_SHIP}from"../../constants";import{itemRow,itemColumn,itemRowDisabled}from"./FulfillmentSelectorItem.style";import{useFulfillmentSelectorState}from"./FulfillmentSelector.hooks";import{FulfillmentSelectorImpossibleError}from"./FulfillmentSelectorImpossibleError";/** * Renders the direct ship item label. * @param {Object} props The component props. * @returns {JSX} */export function FulfillmentSelectorDirectShip(){var _useFulfillmentSelect=useFulfillmentSelectorState(),productId=_useFulfillmentSelect.productId,selection=_useFulfillmentSelect.selection,isOrderable=_useFulfillmentSelect.isOrderable,isDirectShipEnabled=_useFulfillmentSelect.isDirectShipEnabled,isReady=_useFulfillmentSelect.isReady;var rowClasses=React.useMemo(function(){return classNames(itemRow,_defineProperty({},itemRowDisabled.toString(),!isReady||!isDirectShipEnabled));},[isDirectShipEnabled,isReady]);var selected=selection===DIRECT_SHIP;if(selected&&!isOrderable){return React.createElement(React.Fragment,null,React.createElement("div",null,i18n.text(DIRECT_SHIP_LABEL)),React.createElement(FulfillmentSelectorImpossibleError,null));}return React.createElement(Grid,{className:rowClasses,component:"div"},React.createElement(Grid.Item,{className:itemColumn,grow:1,shrink:0,component:"div"},i18n.text(DIRECT_SHIP_LABEL)),React.createElement(Grid.Item,{className:itemColumn,grow:1,shrink:0,component:"div"},isReady&&isDirectShipEnabled&&isOrderable&&React.createElement(Availability,{productId:productId,fulfillmentSelection:DIRECT_SHIP})));}