import React, { useEffect, useRef } from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; import { Button, Icon } from '../'; const Notification = ({ type, message, actions, onSubmit, onOutsideClick }) => { const notificationRef = useRef(null); useEffect(() => { const notificationElement = notificationRef.current; const handleClick = function(event) { const isClickInside = notificationElement.contains(event.target); if (!isClickInside) { onOutsideClick(); } }; document.addEventListener('mousedown', handleClick); return () => { document.removeEventListener('mousedown', handleClick); }; }, [onOutsideClick]); const iconsByType = { error: { icon: 'info', color: 'text-red-700', }, warning: { icon: 'notificationwarning-diamond', color: 'text-yellow-500', }, info: { icon: 'info', color: 'text-primary-main', }, success: { icon: 'info', color: 'text-green-500', }, }; const getIconData = () => { return ( iconsByType[type] || { icon: '', color: '', } ); }; const { icon, color } = getIconData(); return (