import classNames from 'classnames' import { toast as createToast, Slide, ToastContainer } from 'react-toastify' import { mutate } from 'swr' import { CheckCircled, Cross, CrossCircled, ExternalLink } from 'components/Icons' import Text from 'components/Text' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' import { EXPLORER_NAME, EXPLORER_TX_URL } from 'constants/explorer' import { REDUCE_MOTION_KEY } from 'constants/localStore' import useLocalStorage from 'hooks/useLocalStorage' import useStore from 'store' import { TextLink } from './TextLink' export default function Toaster() { const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) const toast = useStore((s) => s.toast) const isError = toast?.isError if (toast) { const Msg = () => (
{isError ? : }
{toast.title ? toast.title : isError ? 'Error' : 'Success'}
{toast.message} {toast.hash && ( {`View on ${EXPLORER_NAME}`} )}
) createToast(Msg, { icon: false, draggable: false, closeOnClick: true, progressClassName: classNames('h-[1px] bg-none', isError ? 'bg-error' : 'bg-success'), }) useStore.setState({ toast: null }) mutate(() => true) } return ( ) }