1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

added toasts

This commit is contained in:
Fedor Katurov 2022-01-04 21:10:05 +07:00
parent ef959af711
commit 39e801f6f3
10 changed files with 92 additions and 7 deletions

20
src/utils/toast/index.tsx Normal file
View file

@ -0,0 +1,20 @@
import React from 'react';
import toast from 'react-hot-toast';
import styles from './styles.module.scss';
import { ToastOptions } from 'react-hot-toast/dist/core/types';
import classNames from 'classnames';
import { isTablet } from '~/constants/dom';
const defaultOptions: ToastOptions = {
icon: null,
duration: 3000,
position: isTablet() ? 'top-center' : 'bottom-center',
};
export const showToastError = (message: string) =>
toast.error(t => <span onClick={() => toast.dismiss(t.id)}>{message}</span>, {
...defaultOptions,
className: classNames(styles.toast, styles.error),
});
export const hideToast = (id: string) => toast.dismiss(id);