UNPKG

@shopgate/engage

Version:
51 lines (50 loc) 1.58 kB
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} */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export function StoreOpeningHours({ hours, pure }) { if (!hours || _every(hours, _isEmpty)) { return null; } const storeHours = /*#__PURE__*/_jsx("div", { className: openingHours, children: /*#__PURE__*/_jsx("table", { children: /*#__PURE__*/_jsx("tbody", { children: getWeekDaysOrder().map(weekDay => /*#__PURE__*/_jsx(StoreOpeningHoursLine, { hours: hours[weekDay], day: weekDay }, weekDay)) }) }) }); if (pure) { return storeHours; } return /*#__PURE__*/_jsxs(StoreDetailsLine, { icon: TimeIcon, children: [/*#__PURE__*/_jsx(I18n.Text, { string: "locations.hours_details", className: detailsSecondary }), storeHours] }); } StoreOpeningHours.defaultProps = { hours: null, pure: false };