ldc-legaulois/resources/ts/modules/toast.ts

36 lines
864 B
TypeScript

import type { Options } from "toastify-js";
import StartToastifyInstance from "toastify-js";
function toast(
message: string,
duration = 4000,
className = "notifications"
): void {
const options: Options = {
duration: duration,
newWindow: false,
close: true,
className: className,
gravity: "top",
offset: {
x: "2em",
y: "3em",
},
// * Prevents dismissing of toast on hover
stopOnFocus: true,
};
options.text = message;
StartToastifyInstance(options).showToast();
};
function notify(message: string, duration = 4000): void {
toast(message, duration, "notifications success");
};
function errorNotify(message: string, duration = 4000): void {
toast(message, duration, "notifications error");
}
export {
errorNotify, notify
};