import { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import Loader from 'react-loader'; import { defineMessages, injectIntl } from 'react-intl'; import { mdiAlert, mdiCheckboxMarkedCircleOutline, mdiClose } from '@mdi/js'; import { Icon } from '../ui/icon'; const icons = { 'checkbox-marked-circle-outline': mdiCheckboxMarkedCircleOutline, alert: mdiAlert, }; const messages = defineMessages({ dismiss: { id: 'infobox.dismiss', defaultMessage: 'Dismiss', }, }); class Infobox extends Component { static propTypes = { // eslint-disable-next-line react/forbid-prop-types children: PropTypes.any.isRequired, icon: PropTypes.string, type: PropTypes.string, ctaOnClick: PropTypes.func, ctaLabel: PropTypes.string, ctaLoading: PropTypes.bool, dismissable: PropTypes.bool, onDismiss: PropTypes.func, onSeen: PropTypes.func, }; static defaultProps = { icon: '', type: 'primary', dismissable: false, ctaOnClick: () => null, ctaLabel: '', ctaLoading: false, onDismiss: () => null, onSeen: () => null, }; state = { dismissed: false, }; componentDidMount() { const { onSeen } = this.props; if (onSeen) onSeen(); } render() { const { children, icon, type, ctaLabel, ctaLoading, ctaOnClick, dismissable, onDismiss, } = this.props; const { intl } = this.props; if (this.state.dismissed) { return null; } return (
{icon && }
{children}
{ctaLabel && ( )} {dismissable && ( )}
); } } export default injectIntl(observer(Infobox));