2023-02-26 19:55:04 +03:00
|
|
|
import Toastify from 'toastify-js';
|
|
|
|
|
2023-09-21 14:44:26 +03:00
|
|
|
window._showToast = showToast;
|
|
|
|
|
2023-02-26 19:55:04 +03:00
|
|
|
function showToast(props) {
|
|
|
|
if (typeof props === 'string') {
|
|
|
|
props = { text: props };
|
|
|
|
}
|
2023-03-06 11:01:33 +03:00
|
|
|
const { onClick, delay, ...rest } = props;
|
2023-02-26 19:55:04 +03:00
|
|
|
const toast = Toastify({
|
2023-03-06 11:01:33 +03:00
|
|
|
className: `${onClick || props.destination ? 'shiny-pill' : ''}`,
|
2023-02-26 19:55:04 +03:00
|
|
|
gravity: 'bottom',
|
|
|
|
position: 'center',
|
|
|
|
...rest,
|
|
|
|
onClick: () => {
|
2023-03-06 11:01:33 +03:00
|
|
|
onClick?.(toast); // Pass in the object itself!
|
2023-02-26 19:55:04 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
if (delay) {
|
|
|
|
setTimeout(() => {
|
|
|
|
toast.showToast();
|
|
|
|
}, delay);
|
|
|
|
} else {
|
|
|
|
toast.showToast();
|
|
|
|
}
|
2023-12-27 18:33:59 +03:00
|
|
|
return toast;
|
2023-02-26 19:55:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default showToast;
|