UNPKG

@shopgate/engage

Version:
68 lines (67 loc) 1.89 kB
import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; import { css } from 'glamor'; import FulfillmentSlotSwitcherDefault from "./FulfillmentSlotSwitcherDefault"; import FulfillmentSlotSwitcherBar from "./FulfillmentSlotSwitcherBar"; import connect from "./FulfillmentSlotSwitcher.connector"; import { forceOpenFulfillmentSlotDialog } from "./FulfillmentSlotProvider"; import { jsx as _jsx } from "react/jsx-runtime"; const styles = { card: css({ boxShadow: '0px 4px 2px rgba(0, 0, 0, 0.05)', marginBottom: 16, ' > div > div': { borderBottom: 0 }, ' > div': { borderRadius: 5, margin: -1, background: '#fff', border: '1px solid #eaeaea' } }).toString() }; /** * @returns {JSX} */ const FulfillmentSlotSwitcher = ({ fulfillmentSlot, renderBar, isFulfillmentScheduling, isFulfillmentSlotValid, standalone, card, editable }) => { // Handle sheet. const handleOpen = useCallback(() => { forceOpenFulfillmentSlotDialog(); }, []); if (!isFulfillmentScheduling) { return null; } return renderBar ? /*#__PURE__*/_jsx("div", { className: card ? styles.card : undefined, children: /*#__PURE__*/_jsx(FulfillmentSlotSwitcherBar, { fulfillmentSlot: isFulfillmentSlotValid ? fulfillmentSlot : null, handleChange: handleOpen, standalone: standalone, editable: editable }) }) : /*#__PURE__*/_jsx(FulfillmentSlotSwitcherDefault, { fulfillmentSlot: isFulfillmentSlotValid ? fulfillmentSlot : null, handleChange: handleOpen, standalone: standalone, editable: editable }); }; FulfillmentSlotSwitcher.defaultProps = { isFulfillmentScheduling: false, fulfillmentSlot: null, renderBar: false, editable: true, card: false, standalone: false, isFulfillmentSlotValid: true }; export default connect(FulfillmentSlotSwitcher);