@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 1.28 kB
JavaScript
import React,{useContext}from'react';import{CardList,SurroundPortals}from'@shopgate/engage/components';import PlaceholderLabel from'@shopgate/pwa-ui-shared/PlaceholderLabel';import{FulfillmentContext}from"../../locations.context";import{StoreContext}from"./Store.context";import{StoreCard}from"./StoreCard";import{stores,storeCard,storeCardPlaceholder}from"./Store.style";import{FULFILLMENT_SHEET_STORE_LIST}from"../../constants/Portals";/**
* Renders the locations.
* @returns {JSX.Element}
*/function StoreListLocations(){var _useContext=useContext(FulfillmentContext),locations=_useContext.locations,isLoading=_useContext.isLoading;if(!isLoading&&(!locations||locations.length===0)){return null;}var showPlaceholder=isLoading&&(!locations||locations.length===0);return React.createElement(SurroundPortals,{portalName:FULFILLMENT_SHEET_STORE_LIST,portalProps:{locations:locations}},React.createElement(CardList,{className:stores},React.createElement(PlaceholderLabel,{className:storeCardPlaceholder,ready:!showPlaceholder},locations.map(function(location){return React.createElement(CardList.Item,{className:storeCard,key:location.code},React.createElement(StoreContext.Provider,{value:location},React.createElement(StoreCard,null)));}))));}export default StoreListLocations;