2023-10-12 15:56:11 +02:00
|
|
|
import type { Options } from "toastify-js";
|
|
|
|
|
import * as Toastify from "toastify-js";
|
2022-08-30 13:21:07 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
methods: {
|
|
|
|
|
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;
|
2023-10-12 15:56:11 +02:00
|
|
|
Toastify.default(options).showToast();
|
2022-08-30 13:21:07 +00:00
|
|
|
},
|
2023-10-12 15:56:11 +02:00
|
|
|
notify(message: string, duration = 4000): void {
|
|
|
|
|
this.toast(message, duration, "notifications");
|
2022-08-30 13:21:07 +00:00
|
|
|
},
|
2023-10-12 15:56:11 +02:00
|
|
|
errorNotify(message: string, duration = 4000): void {
|
|
|
|
|
this.toast(message, duration, "notifications error");
|
2022-08-30 13:21:07 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|