@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 1.8 kB
JavaScript
import*as React from'react';import PropTypes from'prop-types';import{StoreContext}from"./Store.context";import{FulfillmentContext}from"../../locations.context";import{StockInfo}from"../StockInfo";import{LocationIcon}from"../../../components";import{i18n}from"../../../core";import{address as container,addressIcon,stockInfoContainer}from"./Store.style";/**
* Renders the pickup location's address information.
* @param {Object} props The component props.
* @param {Object} props.address The address object.
* @param {boolean} props.pure Whether to only render the address without any wrapper components.
* @returns {JSX.Element}
*/export function StoreAddress(_ref){var address=_ref.address,pure=_ref.pure;var store=React.useContext(StoreContext);var _React$useContext=React.useContext(FulfillmentContext),product=_React$useContext.product;if(!address){return null;}var addressContent=React.createElement("div",null,React.createElement("div",{"data-test-id":"street"},address.street),address.street2&&address.street2!==''&&React.createElement("div",{"data-test-id":"street2"},address.street2),address.street3&&address.street3!==''&&React.createElement("div",{"data-test-id":"street3"},address.street3),address.street4&&address.street4!==''&&React.createElement("div",{"data-test-id":"street4"},address.street4),i18n.text('locations.address',address));if(pure){return addressContent;}return React.createElement("div",{className:container},React.createElement("div",{className:addressIcon,"aria-hidden":true},React.createElement(LocationIcon,null)),React.createElement("div",null,addressContent,product&&React.createElement("div",{className:stockInfoContainer},React.createElement(StockInfo,{location:store,product:product,showStoreName:false}))));}StoreAddress.defaultProps={address:null,pure:false};