import { Dispatch, SetStateAction, useState } from 'react'; import Toast from '../component/common/Toast/Toast'; export interface IToast { show: boolean; type: 'success' | 'info' | 'warning' | 'error'; text: string; } export type TSetToastData = Dispatch>; const useToast = () => { const [toastData, setToastData] = useState({ show: false, type: 'success', text: '', }); const hideToast = () => { setToastData((prev: IToast) => ({ ...prev, show: false })); }; const toast = ( ); return { toast, setToastData, hideToast }; }; export default useToast;