..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | import { toast as hotToast } from 'react-hot-toast'
import {
MdInfoOutline,
MdCheckCircleOutline,
MdOutlineWarningAmber,
MdErrorOutline
} from 'react-icons/md'
const ToastTypeMap = {
info: { icon: MdInfoOutline, className: 'alert-info' },
success: { icon: MdCheckCircleOutline, className: 'alert-success' },
warning: { icon: MdOutlineWarningAmber, className: 'alert-warning' },
error: { icon: MdErrorOutline, className: 'alert-error' }
}
const _helper = (type: keyof typeof ToastTypeMap) => {
const { icon: Icon, className } = ToastTypeMap[type]
return (message: string) =>
hotToast.custom((t) => {
return (
<div className={`alert ${className} w-fit shadow-lg`}>
<div>
<Icon className="w-6 h-6" /> {message}
</div>
</div>
)
})
}
const toast = {
info: _helper('info'),
success: _helper('success'),
warning: _helper('warning'),
error: _helper('error')
}
export default toast
|
|