UNPKG

@shopgate/engage

Version:
71 lines (69 loc) 2.36 kB
import _isEmpty from "lodash/isEmpty"; import _every from "lodash/every"; import React from 'react'; import PropTypes from 'prop-types'; import { ResponsiveContainer } from '@shopgate/engage/components'; import { useCartItem } from "../CartItem"; import { CartItemCardReservationLabel } from "./CartItemCardReservationLabel"; import connect from "./CartItem.connector"; import { CartItemCardReservationAccordion } from "./CartItemCardReservationAccordion"; import { accordionToggle } from "./CartItemCard.style"; // eslint-disable-next-line max-len /** @typedef {import('@shopgate/engage/locations/locations.types').OptionalLocationAware} OptionalLocationAware */ /** * Renders the cart item card reservation block, * @param {OptionalLocationAware} props The component props. * @returns {JSX.Element} */ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; const CartItemCardReservation = ({ location, fulfillmentMethod }) => { const { isOrderDetails } = useCartItem(); if (!location) { return null; } const { operationHours, address: { phoneNumber } = {} } = location; if ((!operationHours || _every(operationHours, _isEmpty)) && !phoneNumber && (!location.address || !location.address.street)) { return /*#__PURE__*/_jsx("div", { className: accordionToggle, children: /*#__PURE__*/_jsx(CartItemCardReservationLabel, { location: location, fulfillmentMethod: fulfillmentMethod }) }); } return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(ResponsiveContainer, { webOnly: true, breakpoint: ">xs", children: !isOrderDetails && /*#__PURE__*/_jsx(CartItemCardReservationAccordion, { openWithChevron: true, location: location, fulfillmentMethod: fulfillmentMethod, operationHours: operationHours }) }), /*#__PURE__*/_jsx(ResponsiveContainer, { appAlways: true, breakpoint: "<=xs", children: !isOrderDetails && /*#__PURE__*/_jsx(CartItemCardReservationAccordion, { location: location, fulfillmentMethod: fulfillmentMethod, operationHours: operationHours }) })] }); }; CartItemCardReservation.defaultProps = { location: null, fulfillmentMethod: null }; export default connect(CartItemCardReservation);