mars-v2-frontend/src/components/Toaster.tsx
Linkie Link 493ec7c44c
fix: reanabled fundAccount and created base for toasts (#103)
* fix: reanabled fundAccount and created base for toasts

* Update toaster + add router refresh

---------

Co-authored-by: bwvdhelm <34470358+bobthebuidlr@users.noreply.github.com>
2023-02-28 09:20:53 +01:00

32 lines
736 B
TypeScript

'use client'
import { useRouter } from 'next/navigation'
import { toast as createToast, Slide, ToastContainer } from 'react-toastify'
import useStore from 'store'
export default function Toaster() {
const enableAnimations = useStore((s) => s.enableAnimations)
const toast = useStore((s) => s.toast)
const router = useRouter()
if (toast) {
if (toast.isError) {
createToast.error(toast.message)
} else {
createToast.success(toast.message)
}
useStore.setState({ toast: null })
router.refresh()
}
return (
<ToastContainer
autoClose={3000}
closeButton={false}
position='bottom-right'
newestOnTop
transition={enableAnimations ? Slide : undefined}
/>
)
}