@shopgate/engage
Version:
Shopgate's ENGAGE library.
61 lines (59 loc) • 1.55 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Toggle } from '@shopgate/engage/components';
import { root, checkbox, rightSpace, text } from "./style";
import connect from "./connector";
/**
* Renders the cart reservation card label.
* @param {Object} props The component props.
* @returns {JSX.Element}
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const Substitution = ({
id,
onChange,
checked,
className,
label,
disabled
}) => /*#__PURE__*/_jsxs("div", {
className: classNames(root, className),
children: [/*#__PURE__*/_jsx("label", {
"aria-hidden": true,
className: text,
htmlFor: id,
id: `${id}-label`,
children: label
}), /*#__PURE__*/_jsx("div", {
className: rightSpace,
children: /*#__PURE__*/_jsx(Toggle, {
className: checkbox,
checked: checked,
id: id,
onChange: onChange,
disabled: disabled
})
})]
});
Substitution.defaultProps = {
className: undefined,
disabled: false,
checked: false
};
/**
* Gate component for Substitution.
* @param {Object} props The component props.
* @returns {JSX}
*/
const Wrapper = ({
substitutionPreferencesEnabled,
children
}) => substitutionPreferencesEnabled ? children : null;
Wrapper.propTypes = {
children: PropTypes.node.isRequired,
substitutionPreferencesEnabled: PropTypes.bool.isRequired
};
const ConnectedWrapper = connect(Wrapper);
export { ConnectedWrapper as SubstitutionWrapper };
export default Substitution;