floranet/src/functions/quasarNotify.js

36 lines
786 B
JavaScript

import { Notify } from "quasar";
export function quasarNotify({ message = "", type, timeout = 1000 }) {
const obj = {
success: () =>
Notify.create({
message,
color: "positive",
position: "top",
icon: "check_circle",
timeout,
}),
warning: () =>
Notify.create({
message,
color: "warning",
position: "top",
icon: "report_problem",
timeout,
}),
erro: () =>
Notify.create({
message,
color: "negative",
position: "top",
icon: "report_problem",
timeout,
}),
};
if (type) {
return obj[type]() || console.error(`Type is invalid! TYPE: ${type}`);
}
console.error("Type is required, success, warning or erro");
}