This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
EvoCalculator/src/client/Elements/Notification.ts
2022-02-22 13:29:37 +03:00

18 lines
597 B
TypeScript

import { notification } from 'antd';
import { ArgsProps, NotificationInstance } from 'antd/lib/notification';
import { NOTIFICATION_DEBOUNCE } from 'core/constants/debounce';
import { debounce } from 'lodash';
const defaultOptions: Partial<ArgsProps> = {
placement: 'bottomRight',
};
type NotificationOptions = ArgsProps & {
type: keyof NotificationInstance;
};
export const openNotification = debounce((options: NotificationOptions) => {
if (!options.key) options.key = JSON.stringify(options);
notification[options.type]({ ...defaultOptions, ...options });
}, NOTIFICATION_DEBOUNCE);