32 lines
739 B
TypeScript
32 lines
739 B
TypeScript
import { toast, ToastOptions } from "react-toastify";
|
|
|
|
const showToast = (message : string, type = "info", duration = 3000) => {
|
|
const options: ToastOptions = {
|
|
position: "top-right", // Correct type for position
|
|
autoClose: duration,
|
|
hideProgressBar: false,
|
|
closeOnClick: true,
|
|
pauseOnHover: true,
|
|
draggable: true,
|
|
theme: "colored", // 'colored', 'light', or 'dark'
|
|
};
|
|
|
|
switch (type) {
|
|
case "success":
|
|
toast.success(message, options);
|
|
break;
|
|
case "error":
|
|
toast.error(message, options);
|
|
break;
|
|
case "warn":
|
|
toast.warn(message, options);
|
|
break;
|
|
case "info":
|
|
default:
|
|
toast.info(message, options);
|
|
break;
|
|
}
|
|
};
|
|
|
|
export default showToast;
|