@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'
55import { MessageBar , MessageBarType , IconButton } from 'office-ui-fabric-react'
66import { NeuronWalletContext } from 'states/stateProvider'
77import { StateWithDispatch , AppActions } from 'states/stateProvider/reducer'
8+ import styles from './Notification.module.scss'
89
910const notificationType = ( type : 'success' | 'warning' | 'alert' ) => {
1011 switch ( type ) {
@@ -29,7 +30,7 @@ const DismissButton = ({ onDismiss }: { onDismiss: React.MouseEventHandler<HTMLB
2930
3031const NoticeContent = ( { dispatch } : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
3132 const {
32- app : { notifications = [ ] } ,
33+ app : { notifications = [ ] , popups = [ ] } ,
3334 } = useContext ( NeuronWalletContext )
3435 const [ t ] = useTranslation ( )
3536 const onDismiss = useCallback ( ( ) => {
@@ -38,28 +39,36 @@ const NoticeContent = ({ dispatch }: React.PropsWithoutRef<StateWithDispatch & R
3839 payload : null ,
3940 } )
4041 } , [ dispatch ] )
41- if ( ! notifications . length ) {
42- return null
43- }
4442
4543 const notification = notifications [ 0 ]
4644
4745 return (
48- < MessageBar
49- messageBarType = { notificationType ( notification . type ) }
50- styles = { {
51- root : {
52- flexDirection : 'row' ,
53- } ,
54- actions : {
55- margin : 0 ,
56- marginRight : '12px' ,
57- } ,
58- } }
59- actions = { < DismissButton onDismiss = { onDismiss } /> }
60- >
61- { t ( notification . content ) }
62- </ MessageBar >
46+ < div >
47+ { notifications . length ? (
48+ < MessageBar
49+ messageBarType = { notificationType ( notification . type ) }
50+ styles = { {
51+ root : {
52+ flexDirection : 'row' ,
53+ } ,
54+ actions : {
55+ margin : 0 ,
56+ marginRight : '12px' ,
57+ } ,
58+ } }
59+ actions = { < DismissButton onDismiss = { onDismiss } /> }
60+ >
61+ { t ( notification . content ) }
62+ </ MessageBar >
63+ ) : null }
64+ < div className = { styles . autoDismissMessages } >
65+ { popups . map ( popup => (
66+ < MessageBar key = { `${ popup . timestamp } ` } messageBarType = { MessageBarType . success } >
67+ { t ( popup . text ) }
68+ </ MessageBar >
69+ ) ) }
70+ </ div >
71+ </ div >
6372 )
6473}
6574
0 commit comments