import React, { useState } from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; import Button from '../../ui/button'; import Checkbox from '../../ui/check-box'; import Tooltip from '../../ui/tooltip'; const HomeNotification = ({ acceptText, checkboxText, checkboxTooltipText, classNames = [], descriptionText, ignoreText, infoText, onAccept, onIgnore, }) => { const [checkboxState, setCheckBoxState] = useState(false); const checkboxElement = checkboxText && ( setCheckBoxState((checked) => !checked)} /> ); return (
{descriptionText}
{infoText ? ( ) : null}
{onAccept && acceptText ? ( ) : null} {onIgnore && ignoreText ? ( ) : null} {checkboxText ? (
{checkboxTooltipText ? ( {checkboxElement} ) : ( checkboxElement )}
) : null}
); }; HomeNotification.propTypes = { /** * The text for the "Accept" button. This must be accompanied by the `onAccept` prop. * * The "Accept" button is only rendered if this prop is set. */ acceptText: PropTypes.node, /** * The text to display alongside the checkbox. * * The checkbox state is passed to the `onIgnore` handler, so this should only be used if the `onIgnore` prop is set. * * The checkbox is only rendered if this prop is set. */ checkboxText: PropTypes.node, /** * The text to display in the checkbox tooltip. * * The tooltip is only rendered if this prop is set. */ checkboxTooltipText: PropTypes.node, /** * Custom class names. */ classNames: PropTypes.array, /** * The notification description. */ descriptionText: PropTypes.node.isRequired, /** * The text for the "Ignore" button. This must be accompanied by the `onIgnore` prop. * * The "Ignore" button is only rendered if this prop is set. */ ignoreText: PropTypes.node, /** * The text for the info icon tooltip in the top-right of the notification. * * The info-icon is only rendered if this prop is set. */ infoText: PropTypes.node, /** * The handler for the "Accept" button. This must be accompanied by the `acceptText` prop. */ onAccept: PropTypes.func, /** * The handler for the "Ignore" button. This must be accompanied by the `ignoreText` prop. * * If `checkboxText` is set, the checkbox state will be passed to this function as a boolean. */ onIgnore: PropTypes.func, }; export default HomeNotification;