@@ -53,10 +53,11 @@ import useSiren from "../utils/sirenHook";
5353 * @param {Function } props.renderListEmpty - Function to render content when the notification list is empty.
5454 * @param {ReactNode } props.customFooter - Custom footer component to be rendered below the notification list.
5555 * @param {ReactNode } pros.customLoader - Custom Loader component to be rendered while fetching notification list for the first time
56- * @param {ReactNode } pros.loadMoreComponent -Custom load more component to be rendered
56+ * @param {ReactNode } pros.loadMoreComponent -Custom load more component to be rendered
5757 * @param {ReactNode } props.customErrorWindow -Custom error window component to be rendered when there is an error
5858 * @param {Function } props.customNotificationCard - Function to render custom notification cards.
5959 * @param {Function } props.onNotificationCardClick - Callback function executed when a notification card is clicked.
60+ * @param {DimensionValue } props.modalWidth - The width of the notification panel.
6061 * @returns {ReactElement } The rendered SirenInbox component.
6162 */
6263
@@ -84,6 +85,7 @@ const SirenPanel: FC<SirenPanelProps> = ({
8485 customNotificationCard,
8586 onNotificationCardClick,
8687 onError,
88+ modalWidth,
8789} ) => {
8890 const {
8991 markNotificationsAsViewed,
@@ -97,7 +99,7 @@ const SirenPanel: FC<SirenPanelProps> = ({
9799 ) ;
98100
99101 const [ error , setError ] = useState < string > ( "" ) ;
100- const [ isLoading , setIsLoading ] = useState ( false ) ;
102+ const [ isLoading , setIsLoading ] = useState ( true ) ;
101103 const [ endReached , setEndReached ] = useState ( false ) ;
102104 const [ eventListenerData , setEventListenerData ] =
103105 useState < EventListenerDataType | null > ( null ) ;
@@ -139,7 +141,6 @@ const SirenPanel: FC<SirenPanelProps> = ({
139141 }
140142 } , [ siren , verificationStatus , hideBadge ] ) ;
141143
142-
143144 const restartNotificationCountFetch = ( ) => {
144145 try {
145146 siren ?. startRealTimeUnviewedCountFetch ( ) ;
@@ -173,7 +174,7 @@ const SirenPanel: FC<SirenPanelProps> = ({
173174 const response = await deleteNotificationsByDate (
174175 notifications [ 0 ] . createdAt
175176 ) ;
176-
177+
177178 response && triggerOnError ( response ) ;
178179
179180 if ( response && isValidResponse ( response ) ) {
@@ -197,7 +198,8 @@ const SirenPanel: FC<SirenPanelProps> = ({
197198
198199 setNotifications ( updatedNotifications ) ;
199200
200- if ( isRefresh ) handleMarkNotificationsAsViewed ( updatedNotifications [ 0 ] . createdAt ) ;
201+ if ( isRefresh )
202+ handleMarkNotificationsAsViewed ( updatedNotifications [ 0 ] . createdAt ) ;
201203 } ;
202204
203205 const fetchNotifications = async ( isRefresh = false ) => {
@@ -221,17 +223,15 @@ const SirenPanel: FC<SirenPanelProps> = ({
221223 if ( ! isEmptyArray ( response . data ?? [ ] ) ) {
222224 data = filterDataProperty ( response ) ;
223225 if ( ! data ) return [ ] ;
224- if ( response ?. meta ) {
225-
226- const isLastPage = response ?. meta ?. last === 'true' ;
226+ if ( response ?. meta ) {
227+ const isLastPage = response ?. meta ?. last === "true" ;
227228
228- if ( isLastPage ) setEndReached ( true ) ;
229+ if ( isLastPage ) setEndReached ( true ) ;
229230 else setEndReached ( false ) ;
230231 }
231232 updateNotificationList ( data , isRefresh ) ;
232233 }
233- if ( ! data )
234- setEndReached ( true ) ;
234+ if ( ! data ) setEndReached ( true ) ;
235235 resetRealTimeFetch ( isRefresh , data ) ;
236236 } else {
237237 setEndReached ( true ) ;
@@ -318,26 +318,33 @@ const SirenPanel: FC<SirenPanelProps> = ({
318318 if ( isLoading && isEmptyArray ( notifications ) )
319319 return (
320320 < div className = "siren-sdk-list-loader-container" >
321- { customLoader ||
322- < >
323- < AnimatedLoader styles = { styles } />
324- < AnimatedLoader styles = { styles } />
325- < AnimatedLoader styles = { styles } />
326- < AnimatedLoader styles = { styles } />
327- < AnimatedLoader styles = { styles } />
328- </ > }
321+ { customLoader || (
322+ < >
323+ < AnimatedLoader styles = { styles } />
324+ < AnimatedLoader styles = { styles } />
325+ < AnimatedLoader styles = { styles } />
326+ < AnimatedLoader styles = { styles } />
327+ < AnimatedLoader styles = { styles } />
328+ </ >
329+ ) }
329330 </ div >
330331 ) ;
331332
332333 if ( error )
333334 return (
334- customErrorWindow || < ErrorWindow styles = { styles } error = { error } darkMode = { darkMode } />
335+ customErrorWindow || (
336+ < ErrorWindow styles = { styles } error = { error } darkMode = { darkMode } />
337+ )
335338 ) ;
336339
337340 if ( isEmptyArray ( notifications ) )
338341 return (
339342 listEmptyComponent || (
340- < EmptyList data-testid = "empty-list" styles = { styles } darkMode = { darkMode } />
343+ < EmptyList
344+ data-testid = "empty-list"
345+ styles = { styles }
346+ darkMode = { darkMode }
347+ />
341348 )
342349 ) ;
343350
@@ -359,19 +366,24 @@ const SirenPanel: FC<SirenPanelProps> = ({
359366 } ;
360367
361368 const renderListBottomComponent = ( ) => {
362- if (
363- isEmptyArray ( notifications )
364- )
365- return null ;
366- if ( isLoading && ! endReached )
369+ if ( isEmptyArray ( notifications ) ) return null ;
370+ if ( isLoading && ! endReached )
367371 return (
368- < div className = "siren-sdk-panel-infinite-loader-container" >
369- < div className = "siren-sdk-panel-infinite-loader" style = { styles . infiniteLoader } />
372+ < div className = "siren-sdk-panel-infinite-loader-container" >
373+ < div
374+ className = "siren-sdk-panel-infinite-loader"
375+ style = { styles . infiniteLoader }
376+ />
370377 </ div >
371- )
378+ ) ;
372379 if ( ! isLoading && ! endReached )
373380 return (
374- < ShowMoreButton styles = { styles } customComponent = { loadMoreComponent } onClick = { handleLoadMore } loadMoreLabel = { loadMoreLabel } />
381+ < ShowMoreButton
382+ styles = { styles }
383+ customComponent = { loadMoreComponent }
384+ onClick = { handleLoadMore }
385+ loadMoreLabel = { loadMoreLabel }
386+ />
375387 ) ;
376388
377389 return null ;
@@ -383,12 +395,19 @@ const SirenPanel: FC<SirenPanelProps> = ({
383395 "siren-sdk-content-container"
384396 } ${ customFooter ? "siren-sdk-panel-no-border" : "" } `;
385397
398+ const panelStyle = {
399+ ...( ! fullScreen && styles . windowTopBorder ) ,
400+ ...( ! fullScreen && { width : `${ modalWidth } px` } ) ,
401+ ...( ! fullScreen && styles . windowBottomBorder ) ,
402+ ...styles . container ,
403+ } ;
404+
386405 return (
387406 < div
388407 className = {
389408 ! fullScreen ? "siren-sdk-panel-modal" : "siren-sdk-panel-container"
390409 }
391- style = { { ... ( ! fullScreen && styles . windowTopBorder ) , ... ( ! fullScreen && styles . windowBottomBorder ) , ... styles . container } }
410+ style = { panelStyle }
392411 data-testid = "siren-panel"
393412 >
394413 < div >
@@ -404,11 +423,17 @@ const SirenPanel: FC<SirenPanelProps> = ({
404423 />
405424 ) ) }
406425 < div
407- style = { { ...( ! fullScreen && styles . windowBottomBorder ) , ...styles . contentContainer } }
426+ style = { {
427+ ...( ! fullScreen && styles . windowBottomBorder ) ,
428+ ...styles . contentContainer ,
429+ } }
408430 >
409431 < div
410432 id = "contentContainer"
411- style = { { ...( ! fullScreen && styles . windowBottomBorder ) , ...styles . body } }
433+ style = { {
434+ ...( ! fullScreen && styles . windowBottomBorder ) ,
435+ ...styles . body ,
436+ } }
412437 className = { containerClassNames }
413438 >
414439 { renderList ( ) }
0 commit comments