54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { toast } from 'react-toastify';
|
|
|
|
interface IUseNotifyReturn {
|
|
getSuccessNotify: () => number | string;
|
|
getErrorNotifyByNickname: () => number | string;
|
|
getErrorNotifyByCount: () => number | string;
|
|
}
|
|
|
|
export function useNotify(): IUseNotifyReturn {
|
|
const getSuccessNotify = () => {
|
|
return toast.success('Заявка успешно создана!', {
|
|
position: 'top-left',
|
|
autoClose: 3000,
|
|
hideProgressBar: false,
|
|
closeOnClick: true,
|
|
pauseOnHover: true,
|
|
draggable: true,
|
|
style: { width: '250px', color: 'black', margin: '15px' },
|
|
progress: undefined,
|
|
theme: 'dark',
|
|
});
|
|
};
|
|
|
|
const getErrorNotifyByNickname = () => {
|
|
return toast.error('Вы не указали ваш никнейм!', {
|
|
position: 'top-left',
|
|
autoClose: 3000,
|
|
hideProgressBar: false,
|
|
closeOnClick: true,
|
|
pauseOnHover: true,
|
|
draggable: true,
|
|
style: { width: '250px', color: 'black', margin: '15px' },
|
|
progress: undefined,
|
|
theme: 'dark',
|
|
});
|
|
};
|
|
|
|
const getErrorNotifyByCount = () => {
|
|
return toast.error('Вы не можете выбрать количество равное 0!', {
|
|
position: 'top-left',
|
|
autoClose: 3000,
|
|
hideProgressBar: false,
|
|
closeOnClick: true,
|
|
pauseOnHover: true,
|
|
draggable: true,
|
|
style: { width: '250px', color: 'black', margin: '15px' },
|
|
progress: undefined,
|
|
theme: 'dark',
|
|
});
|
|
};
|
|
|
|
return { getSuccessNotify, getErrorNotifyByNickname, getErrorNotifyByCount };
|
|
}
|