import React from 'react'; import cx from 'classnames'; import { useDispatch } from 'react-redux'; import { dismissAlert } from 'redux/actions'; import { Alert as AlertProps } from 'redux/interfaces'; const Alert: React.FC = ({ id, type, title, message, response, }) => { const classNames = React.useMemo( () => cx('notification', { 'is-danger': type === 'error', 'is-success': type === 'success', 'is-info': type === 'info', 'is-warning': type === 'warning', }), [type] ); const dispatch = useDispatch(); const dismiss = React.useCallback(() => { dispatch(dismissAlert(id)); }, []); return (
{title}

{message}

{response && (
{response.status}
{response.body?.message || response.statusText}
)}
); }; export default Alert;