Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* useToast — show toast notifications.
*/
import {useAppStore, type IToast} from '../state/appStore.js';
export interface IUseToastResult {
show: (toast: Omit<IToast, 'id'>) => void;
success: (message: string, detail?: string) => void;
error: (message: string, detail?: string) => void;
info: (message: string, detail?: string) => void;
warn: (message: string, detail?: string) => void;
clear: (id: string) => void;
clearAll: () => void;
}
export function useToast(): IUseToastResult {
const showToast = useAppStore(s => s.showToast);
const clearToast = useAppStore(s => s.clearToast);
const clearAllToasts = useAppStore(s => s.clearAllToasts);
return {
show: showToast,
success: (summary, detail) => showToast({severity: 'success', summary, detail}),
error: (summary, detail) => showToast({severity: 'error', summary, detail}),
info: (summary, detail) => showToast({severity: 'info', summary, detail}),
warn: (summary, detail) => showToast({severity: 'warn', summary, detail}),
clear: clearToast,
clearAll: clearAllToasts,
};
}
|