UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

39 lines (38 loc) 1.45 kB
import { jsx as _jsx } from "react/jsx-runtime"; import ObjectFactory from '../../../Utilities/ObjectFactory'; import { AdaptablePopupAlert } from './AdaptablePopupAlert'; import { toast } from '../../../components/Toastify'; export const showToast = (props) => { let api = props.api; const off = api.eventApi.on('AdaptableDestroy', () => { toast.dismiss(); api = null; }); const adaptableOptions = props.api.optionsApi.getAdaptableOptions(); const toastProps = ObjectFactory.CreateToastOptions(adaptableOptions.notificationsOptions, { containerId: `Toastify-${adaptableOptions.adaptableId}`, onClose: () => { off(); }, }, { duration: props.adaptableAlert.alertDefinition.AlertProperties.NotificationDuration, }); const content = (_jsx(AdaptablePopupAlert, { headless: true, adaptableAlert: props.adaptableAlert, onClose: () => { toast.dismiss(toastId); } })); let toastId; switch (props.adaptableAlert.alertDefinition.MessageType) { case 'Info': toastId = toast.info(content, toastProps); break; case 'Error': toastId = toast.error(content, toastProps); break; case 'Success': toastId = toast.success(content, toastProps); break; case 'Warning': toastId = toast.warn(content, toastProps); break; } };