visua-vue/src/components/composable/useAlert.ts

25 lines
466 B
TypeScript
Raw Normal View History

2025-07-27 09:46:45 +02:00
import { useToast } from "primevue/usetoast";
import type IVAlert from "../alert/IVAlert.type.js";
2025-07-27 09:46:45 +02:00
export function useAlert() {
const toast = useToast();
2025-07-27 09:46:45 +02:00
const showAlert = ({
title = '',
description = '',
type = 'info',
closeable = true,
lifeTime,
}: IVAlert) => {
2025-07-27 09:46:45 +02:00
toast.add({
severity: type,
summary: title,
detail: description,
life: lifeTime,
closable: closeable,
})
}
2025-07-27 09:46:45 +02:00
return { showAlert}
2025-07-27 09:46:45 +02:00
}