UNPKG

@orchestrator-ui/orchestrator-ui-components

Version:

Library of UI Components used to display the workflow orchestrator frontend

24 lines (19 loc) 667 B
import { ReactNode } from 'react'; import { useAppDispatch } from '@/rtk/hooks'; import { addToastMessage } from '@/rtk/slices/toastMessages'; import { ToastTypes } from '@/types'; import { getToastMessage } from '@/utils/getToastMessage'; export const useShowToastMessage = () => { const dispatch = useAppDispatch(); const showToastMessage = ( type: ToastTypes, text: ReactNode, title: string, // same as above for string instead of Toast['title'], ) => { const toastMessage = getToastMessage(type, text, title); dispatch(addToastMessage(toastMessage)); }; return { showToastMessage, }; };