@@ -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,11 @@ 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 = (
131+ message : string ,
132+ messageType : string = "info" ,
133+ onClick : function
134+ ) => changeToasts ( { type : "add" , message, messageType, onClick } )
131135
132136 return (
133137 < >
@@ -141,6 +145,7 @@ export const ToastProvider = ({ children }) => {
141145 < Notification
142146 type = { msg . type }
143147 message = { msg . message }
148+ onClick = { msg . onClick }
144149 onClose = { ( ) => changeToasts ( { type : "remove" , id : msg . id } ) }
145150 />
146151 </ Fade >
@@ -151,7 +156,7 @@ export const ToastProvider = ({ children }) => {
151156 )
152157}
153158
154- export const Notification = ( { type, message, onClose } ) => {
159+ export const Notification = ( { type, message, onClick , onClose } ) => {
155160 const classes = useStyles ( )
156161 let Icon = null
157162 switch ( type ) {
@@ -170,7 +175,8 @@ export const Notification = ({ type, message, onClose }) => {
170175 return (
171176 < paper
172177 className = { classes . notificationPaper }
173- style = { { position : "relative" } }
178+ style = { { position : "relative" , cursor : "pointer" } }
179+ onClick = { onClick }
174180 >
175181 < div className = { classNames ( classes . icon , type ) } >
176182 < Icon fontSize = "large" style = { { padding : 12 } } />
0 commit comments