UNPKG

@shopgate/engage

Version:
4 lines 2 kB
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useCallback,Fragment,memo}from'react';import PropTypes from'prop-types';import{useWidgetSettings,useTheme}from"../../../core";import{SheetDrawer,I18n,Button}from"../../../components";import{WIDGET_ID}from"./constants";import{showMore,sheet}from"./style";import connect from"./RelationsSheet.connector";/** * Shows a Sheet Drawer with all related products. * @returns {JSX} */var RelationsSheet=memo(function(_ref){var products=_ref.products.products;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),show=_useState2[0],setShow=_useState2[1];var _useWidgetSettings=useWidgetSettings(WIDGET_ID),headline=_useWidgetSettings.headline;var _useTheme=useTheme(),ProductGrid=_useTheme.ProductGrid;var handleOpen=useCallback(function(event){event.preventDefault();setShow(true);},[]);var handleClose=useCallback(function(){setShow(false);},[]);return React.createElement(Fragment,null,React.createElement(Button,{onClick:handleOpen,flat:true,className:showMore},React.createElement(I18n.Text,{string:"product.relations.showMore"})),React.createElement(SheetDrawer,{isOpen:show,title:headline,onClose:handleClose},React.createElement("div",{className:sheet},React.createElement(ProductGrid,{products:products,infiniteLoad:false}))));});RelationsSheet.defaultProps={products:{products:[],productCount:0}};export default connect(RelationsSheet);