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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 4x 4x 9x 9x 1x 1x 9x 9x 9x | /**
* @file usePublicShellToast.ts
* @description
* Custom hook for managing toast notification state in public shell.
* Provides show/hide interface with severity levels.
*
* @enterprise
* - Manages toast state with message and severity
* - Provides open/close and setToast interface
* - Integrates with MUI Alert severity types
*
* @example
* ```tsx
* const { toast, showToast, hideToast } = usePublicShellToast();
* ```
*
* @returns Toast state and control functions
*/
import * as React from 'react';
export interface Toast {
/** Toast is currently visible */
open: boolean;
/** Toast message text */
msg: string;
/** Severity level for Alert component */
severity: 'success' | 'info' | 'warning' | 'error';
}
interface UsePublicShellToastReturn {
/** Current toast state */
toast: Toast | null;
/** Show toast with message and severity */
showToast: (msg: string, severity?: 'success' | 'info' | 'warning' | 'error') => void;
/** Hide toast */
hideToast: () => void;
/** Set complete toast state */
setToast: (toast: Toast | null) => void;
}
/**
* usePublicShellToast hook
* @returns Toast state and control functions
*/
export const usePublicShellToast = (): UsePublicShellToastReturn => {
const [toast, setToast] = React.useState<Toast | null>(null);
const showToast = (msg: string, severity: 'success' | 'info' | 'warning' | 'error' = 'success') => {
setToast({ open: true, msg, severity });
};
const hideToast = () => {
setToast((prev) => (prev ? { ...prev, open: false } : null));
};
return { toast, showToast, hideToast, setToast };
};
|