11import React , { useReducer } from 'react'
22import { useIntl , IntlShape } from 'react-intl'
33import { modalActionTypes } from '../actions/modals'
4- import { AlertModal , AppModal } from '../interface'
4+ import { AlertModal , AppModal , ActionNotification } from '../interface'
55import { modalReducer } from '../reducer/modals'
66import { ModalInitialState } from '../state/modals'
77import { ModalTypes } from '../types'
@@ -13,7 +13,7 @@ declare global {
1313}
1414
1515export const ModalProvider = ( { children = [ ] , reducer = modalReducer , initialState = ModalInitialState } = { } ) => {
16- const [ { modals, toasters, focusModal, focusToaster, focusTemplateExplorer } , dispatch ] = useReducer ( reducer , initialState )
16+ const [ { modals, toasters, focusModal, focusToaster, focusTemplateExplorer, actionNotifications } , dispatch ] = useReducer ( reducer , initialState )
1717
1818 const onNextFn = async ( ) => {
1919 dispatch ( {
@@ -84,9 +84,23 @@ export const ModalProvider = ({ children = [], reducer = modalReducer, initialSt
8484 } )
8585 }
8686
87+ const actionNotification = ( data : ActionNotification ) => {
88+ dispatch ( {
89+ type : modalActionTypes . setActionNotification ,
90+ payload : data
91+ } )
92+ }
93+
94+ const hideActionNotification = ( id : string ) => {
95+ dispatch ( {
96+ type : modalActionTypes . hideActionNotification ,
97+ payload : { id }
98+ } )
99+ }
100+
87101 return (
88- < dispatchModalContext . Provider value = { { modal, toast, alert, handleHideModal, handleToaster } } >
89- < modalContext . Provider value = { { modals, toasters, focusModal, focusToaster, focusTemplateExplorer } } >
102+ < dispatchModalContext . Provider value = { { modal, toast, alert, handleHideModal, handleToaster, actionNotification , hideActionNotification } } >
103+ < modalContext . Provider value = { { modals, toasters, focusModal, focusToaster, focusTemplateExplorer, actionNotifications } } >
90104 { children }
91105 </ modalContext . Provider >
92106 </ dispatchModalContext . Provider >
0 commit comments