UNPKG

@shopgate/engage

Version:
65 lines (63 loc) 2.14 kB
import _isEmpty from "lodash/isEmpty"; import _every from "lodash/every"; import React from 'react'; import PropTypes from 'prop-types'; import CardListItem from '@shopgate/pwa-ui-shared/CardList/components/Item'; import { Accordion } from '@shopgate/engage/components'; import { StoreOpeningHours, StorePhoneNumber } from '@shopgate/engage/locations'; import { CartItemGroupReservationLabel } from "./CartItemGroupReservationLabel"; import connect from "./CartItem.connector"; import { accordionToggle, addressDetails, simpleLabel } from "./CartItemGroup.style"; // eslint-disable-next-line max-len /** @typedef {import('@shopgate/engage/locations/locations.types').OptionalLocationAware} OptionalLocationAware */ /** * Renders the product group. * @param {OptionalLocationAware} props The component props. * @returns {JSX.Element|null} */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; function CartItemGroupReservation({ location, fulfillmentMethod }) { if (!location) { return null; } const { operationHours, address: { phoneNumber } = {} } = location; if ((!operationHours || _every(operationHours, _isEmpty)) && !phoneNumber) { return /*#__PURE__*/_jsx(CardListItem, { className: simpleLabel.toString(), children: /*#__PURE__*/_jsx(CartItemGroupReservationLabel, { location: location, fulfillmentMethod: fulfillmentMethod }) }); } return /*#__PURE__*/_jsx(CardListItem, { children: /*#__PURE__*/_jsx(Accordion, { renderLabel: () => /*#__PURE__*/_jsx(CartItemGroupReservationLabel, { location: location, fulfillmentMethod: fulfillmentMethod }), className: accordionToggle, children: /*#__PURE__*/_jsxs("div", { className: addressDetails, children: [/*#__PURE__*/_jsx(StoreOpeningHours, { hours: operationHours }), /*#__PURE__*/_jsx(StorePhoneNumber, { phone: phoneNumber })] }) }) }); } CartItemGroupReservation.defaultProps = { location: null, fulfillmentMethod: null }; export default connect(CartItemGroupReservation);