@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 926 B
JavaScript
import React from'react';import PropTypes from'prop-types';import{i18n}from"../../../core";import{storeHoursToday}from"./Store.style";var weekdays=['sun','mon','tue','wed','thu','fri','sat'];/**
* Renders the store's opening hours for "today".
* @param {Object} props The component props.
* @param {Object} props.hours The store's opening hours.
* @param {boolean} props.longLabel Whether to render the opening hours with a long label
* @returns {JSX.Element}
*/export function StoreHoursToday(_ref){var hours=_ref.hours,longLabel=_ref.longLabel;if(!hours){return null;}var today=weekdays[new Date().getDay()];var hoursToday=hours[today]||null;if(!hoursToday||hoursToday===''){return null;}var label=longLabel?'locations.today_hours_long':'locations.today_hours';return React.createElement("div",{className:storeHoursToday},i18n.text(label,{hours:hoursToday}));}StoreHoursToday.defaultProps={hours:null,longLabel:false};