fuware-be/frontend/src/hooks/useToast.jsx
2024-06-01 12:34:20 +00:00

32 lines
865 B
JavaScript

import Notify from '@components/Notify'
import toast from 'solid-toast'
export default function useToast() {
const notify = {}
notify.show = ({ status, title, description, closable = false }) => {
return toast.custom((t) => (
<Notify
status={status}
title={title}
description={description}
onClose={closable ? () => toast.dismiss(t.id) : null}
/>
))
}
notify.success = ({ title, description, closable = false }) => {
return notify.show({ status: 'success', title, description, closable })
}
notify.error = ({ title, description, closable = false }) => {
return notify.show({ status: 'error', title, description, closable })
}
notify.info = ({ title, description, closable = false }) => {
return notify.show({ status: 'info', title, description, closable })
}
return notify
}