@shopgate/engage
Version:
Shopgate's ENGAGE library.
3 lines • 2.9 kB
JavaScript
import _isEmpty from"lodash/isEmpty";import _every from"lodash/every";import React,{Fragment,useMemo,useContext}from'react';import{Grid,I18n}from'@shopgate/engage/components';import{StoreFinderContext}from"../../locations.context";import{StoreAddress}from"../StoreList/StoreAddress";import{StoreOpeningHours}from"../StoreList/StoreOpeningHours";import{StoreHoursToday}from"../StoreList/StoreHoursToday";import{StoreDistance}from"../StoreList/StoreDistance";import StoreFinderGetDirectionsButton from"./StoreFinderGetDirectionsButton";import StoreFinderLocationHeaderPhoneNumber from"./StoreFinderLocationHeaderPhoneNumber";import{container,headingLine,storeName,storeHours,storeDistance,storeDetailsLine,storeAddress,storePhoneNumber,storeOpeningHours,directionButton}from"./StoreFinderLocationDetailsWide.style";import{StoreFinderSelectLocationButton}from"./StoreFinderSelectLocationButton";import{StoreContext}from"./Store.context";/**
* @returns {JSX}
*/var StoreFinderLocationDetailsWide=function StoreFinderLocationDetailsWide(){var _useContext=useContext(StoreFinderContext),location=_useContext.selectedLocation,locations=_useContext.locations;var hasOperationHours=useMemo(function(){var _ref=location||{},operationHours=_ref.operationHours;return operationHours&&!_every(operationHours,_isEmpty);},[location]);if(!location||locations.length===0){return null;}return React.createElement(StoreContext.Provider,{value:location},React.createElement("div",{className:container},React.createElement(Grid,{className:headingLine},React.createElement(Grid.Item,{grow:1},React.createElement("div",{className:storeName},location.name),React.createElement("div",{className:storeHours},React.createElement(StoreHoursToday,{hours:location.operationHours,longLabel:true}))),React.createElement(Grid.Item,null,React.createElement("div",{className:storeDistance},React.createElement(StoreDistance,{distance:location.distance,unitSystem:location.unitSystem})),React.createElement(StoreFinderSelectLocationButton,null),React.createElement(StoreFinderGetDirectionsButton,{address:location.address,className:directionButton}))),React.createElement(Grid,{className:storeDetailsLine},React.createElement(Grid.Item,null,React.createElement("div",{className:storeAddress},React.createElement(StoreAddress,{pure:true,address:location.address})),location.address.phoneNumber&&React.createElement("div",{className:storePhoneNumber},React.createElement(I18n.Text,{string:"locations.phone"}),': ',React.createElement(StoreFinderLocationHeaderPhoneNumber,{phone:location.address.phoneNumber,pure:true}))),React.createElement(Grid.Item,{className:storeOpeningHours},hasOperationHours&&React.createElement(Fragment,null,React.createElement(I18n.Text,{string:"locations.store_hours"}),':',React.createElement(StoreOpeningHours,{pure:true,hours:location.operationHours}))))));};export default StoreFinderLocationDetailsWide;