import { useEffect, useState } from 'react' import { CheckCircleIcon, InformationCircleIcon, XCircleIcon, } from '@heroicons/react/outline' import useNotificationStore from '../stores/useNotificationStore' const NotificationList = () => { const { notifications, set: setNotificationStore } = useNotificationStore( (s) => s ) useEffect(() => { if (notifications.length > 0) { const id = setInterval(() => { setNotificationStore((state) => { state.notifications = notifications.slice(1, notifications.length) }) }, 5000) return () => { clearInterval(id) } } }, [notifications, setNotificationStore]) const reversedNotifications = [...notifications].reverse() return (
{reversedNotifications.map((n, idx) => ( ))}
) } const Notification = ({ type, message, description, txid }) => { const [showNotification, setShowNotification] = useState(true) if (!showNotification) return null return (
{type === 'success' ? ( ) : null} {type === 'info' && ( )} {type === 'error' && ( )}
{message}
{description ? (

{description}

) : null} {txid ? ( View transaction {txid.slice(0, 8)}... {txid.slice(txid.length - 8)} ) : null}
) } export default NotificationList