23 lines
535 B
TypeScript
23 lines
535 B
TypeScript
'use client'
|
|
|
|
import type { Toast } from './ToastProvider'
|
|
import { useToast } from './ToastProvider'
|
|
|
|
// Hook-Wrapper (komfortabel)
|
|
export function useNotify() {
|
|
const { push, remove, clear } = useToast()
|
|
|
|
const base = (type: Toast['type']) => (title: string, message?: string, opts?: Partial<Omit<Toast, 'id' | 'type'>>) =>
|
|
push({ type, title, message, ...opts })
|
|
|
|
return {
|
|
push,
|
|
remove,
|
|
clear,
|
|
success: base('success'),
|
|
error: base('error'),
|
|
info: base('info'),
|
|
warning: base('warning'),
|
|
}
|
|
}
|