import { useTranslation } from 'next-i18next' import toastMethod from 'react-hot-toast' import { OkIcon, NoIcon, TipIcon, WarningIcon, ChatIcon } from 'shared/components/icons.mjs' const icons = { success: , error: , info: , warning: , accent: , } const Toast = ({ type = 'info', children }) => (
{icons[type]}
{children}
) /* Custom toast methods */ const toastMethods = (t) => ({ info: (children) => toastMethod.custom({children}), warning: (children) => toastMethod.custom({children}), error: (children) => toastMethod.custom({children}), accent: (children) => toastMethod.custom({children}), success: (children) => toastMethod.custom({children}), for: { settingsSaved: () => toastMethod.custom( {t('settingsSaved')} ), backendError: () => toastMethod.custom( {t('backendError')} ¯\_(ツ)_/¯ ), }, }) /* * The toast hook */ export function useToast() { const { t } = useTranslation(['toast']) return toastMethods(t) }