7
7
import { ReactNode , useState , useEffect } from 'react' ;
8
8
import { Box , type SxProps , type Theme } from '@mui/material' ;
9
9
import { Close as CloseIcon , WarningAmber as WarningAmberIcon , Campaign as CampaignIcon } from '@mui/icons-material' ;
10
- import { mergeSx } from "../../utils" ;
11
- import { AnnouncementProps } from "./TopBar" ;
10
+ import { UUID } from 'crypto' ;
11
+ import { mergeSx } from '../../utils' ;
12
12
13
13
const styles = {
14
14
banner : ( theme ) => ( {
@@ -66,6 +66,13 @@ export interface MessageBannerProps {
66
66
announcementInfos ?: AnnouncementProps ;
67
67
}
68
68
69
+ export type AnnouncementProps = {
70
+ announcementId : UUID ;
71
+ message : string ;
72
+ duration : number ;
73
+ severity : string ;
74
+ } ;
75
+
69
76
function MessageBanner ( { children, announcementInfos } : MessageBannerProps ) {
70
77
const [ visible , setVisible ] = useState ( true ) ;
71
78
@@ -84,24 +91,26 @@ function MessageBanner({ children, announcementInfos }: MessageBannerProps) {
84
91
}
85
92
} , [ announcementInfos ] ) ;
86
93
87
- return ( visible && (
88
- < Box sx = { mergeSx ( styles . banner , isInfo ? styles . infoBg : styles . warningBg ) } >
89
- { isInfo && (
90
- < Box sx = { mergeSx ( styles . icon , styles . infoIcon ) } >
91
- < CampaignIcon />
92
- </ Box >
93
- ) }
94
- { ! isInfo && (
95
- < Box sx = { mergeSx ( styles . icon , styles . warningIcon ) } >
96
- < WarningAmberIcon />
94
+ return (
95
+ visible && (
96
+ < Box sx = { mergeSx ( styles . banner , isInfo ? styles . infoBg : styles . warningBg ) } >
97
+ { isInfo && (
98
+ < Box sx = { mergeSx ( styles . icon , styles . infoIcon ) } >
99
+ < CampaignIcon />
100
+ </ Box >
101
+ ) }
102
+ { ! isInfo && (
103
+ < Box sx = { mergeSx ( styles . icon , styles . warningIcon ) } >
104
+ < WarningAmberIcon />
105
+ </ Box >
106
+ ) }
107
+ < Box sx = { styles . message } > { children } </ Box >
108
+ < Box sx = { styles . button } onClick = { ( ) => setVisible ( false ) } >
109
+ < CloseIcon />
97
110
</ Box >
98
- ) }
99
- < Box sx = { styles . message } > { children } </ Box >
100
- < Box sx = { styles . button } onClick = { ( ) => setVisible ( false ) } >
101
- < CloseIcon />
102
111
</ Box >
103
- </ Box >
104
- ) ) ;
112
+ )
113
+ ) ;
105
114
}
106
115
107
116
export default MessageBanner ;
0 commit comments