@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 1.32 kB
JavaScript
import _isEmpty from"lodash/isEmpty";import _every from"lodash/every";import React from'react';import PropTypes from'prop-types';import{getWeekDaysOrder}from'@shopgate/engage/core';import{I18n,TimeIcon}from'@shopgate/engage/components';import{StoreDetailsLine}from"./StoreDetailsLine";import{StoreOpeningHoursLine}from"./StoreOpeningHoursLine";import{openingHours,detailsSecondary}from"./Store.style";/**
* Renders the store's opening hours.
* @param {Object} props The component props.
* @param {Object} props.hours The store's opening hours.
* @param {boolean} props.pure Whether to render the opening hours without any wrapper components
* @returns {JSX.Element}
*/export function StoreOpeningHours(_ref){var hours=_ref.hours,pure=_ref.pure;if(!hours||_every(hours,_isEmpty)){return null;}var storeHours=React.createElement("div",{className:openingHours},React.createElement("table",null,React.createElement("tbody",null,getWeekDaysOrder().map(function(weekDay){return React.createElement(StoreOpeningHoursLine,{hours:hours[weekDay],day:weekDay,key:weekDay});}))));if(pure){return storeHours;}return React.createElement(StoreDetailsLine,{icon:TimeIcon},React.createElement(I18n.Text,{string:"locations.hours_details",className:detailsSecondary}),storeHours);}StoreOpeningHours.defaultProps={hours:null,pure:false};