@@ -95,6 +95,7 @@ export const ToastProvider = ({ children }) => {
9595 id : Math . random ( ) . toString ( ) . split ( "." ) [ 1 ] ,
9696 message : action . message ,
9797 type : action . messageType ,
98+ onClick : action . onClick || null ,
9899 life : fullLife ,
99100 fullLife,
100101 } ,
@@ -126,8 +127,8 @@ export const ToastProvider = ({ children }) => {
126127 return ( ) => clearInterval ( interval )
127128 } , [ toasts ] )
128129
129- const addToast = ( message : string , messageType : string = "info" ) =>
130- changeToasts ( { type : "add" , message, messageType } )
130+ const addToast = ( message : string , messageType : string = "info" , onClick : function = null ) =>
131+ changeToasts ( { type : "add" , message, messageType, onClick } )
131132
132133 return (
133134 < >
@@ -141,6 +142,7 @@ export const ToastProvider = ({ children }) => {
141142 < Notification
142143 type = { msg . type }
143144 message = { msg . message }
145+ onClick = { msg . onClick }
144146 onClose = { ( ) => changeToasts ( { type : "remove" , id : msg . id } ) }
145147 />
146148 </ Fade >
@@ -151,7 +153,7 @@ export const ToastProvider = ({ children }) => {
151153 )
152154}
153155
154- export const Notification = ( { type, message, onClose } ) => {
156+ export const Notification = ( { type, message, onClick , onClose } ) => {
155157 const classes = useStyles ( )
156158 let Icon = null
157159 switch ( type ) {
@@ -170,7 +172,12 @@ export const Notification = ({ type, message, onClose }) => {
170172 return (
171173 < paper
172174 className = { classes . notificationPaper }
173- style = { { position : "relative" } }
175+ style = { { position : "relative" , cursor : 'pointer' } }
176+ onClick = { ( ) => {
177+ if ( onClick ) {
178+ onClick ( )
179+ }
180+ } }
174181 >
175182 < div className = { classNames ( classes . icon , type ) } >
176183 < Icon fontSize = "large" style = { { padding : 12 } } />
0 commit comments