18 lines
597 B
TypeScript
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);
|