All files / src/hooks use-toast.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 5/5
100% Lines 11/11

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            6x 41x   41x 6x   41x 5x   41x 1x   41x 1x   41x    
import { useUIStore } from '@/store/ui-store';
 
/**
 * Hook for using toasts in components
 * Provides individual toast functions for better discoverability and type safety
 */
export const useToast = () => {
  const { addToast } = useUIStore();
 
  const successToast = (message: string, duration: number = 3000) =>
    addToast({ type: 'success', message, duration });
 
  const errorToast = (message: string, duration: number = 3000) =>
    addToast({ type: 'error', message, duration });
 
  const warningToast = (message: string, duration: number = 3000) =>
    addToast({ type: 'warning', message, duration });
 
  const infoToast = (message: string, duration: number = 3000) =>
    addToast({ type: 'info', message, duration });
 
  return { successToast, errorToast, warningToast, infoToast };
};