toastservice.ts
typescript
a month ago
652 B
3
Indexable
Never
import { useToast } from "primevue/usetoast"; export default class ToastService { public toast = useToast(); private severity: string; private summary: string; makeToast($success: boolean, $message: string, $detail: string = "") { if ($success) this.severity = 'success'; else this.severity = 'error'; if ($message === "OK") this.summary = 'Success!'; else this.summary = $message; this.toast.add({ severity: this.severity, summary: this.summary, detail: $detail, life: 3000, }); } }