1- import React , { useState } from 'react' ;
1+ import React , { useState } from 'react' ;
22
33import { Button } from '@orfium/ictinus' ;
44import {
@@ -85,45 +85,63 @@ const LandingPage: React.FC = () => {
8585 history . push ( `${ urls . patients ( ) } /${ hospital_id } /${ patient_id } ${ urls . episodes ( ) } /${ id } ` ) ;
8686 } ;
8787
88- const { data : announcementsData , isLoading : isLoadingAnnouncements } = useGetAnnouncements ( ) ;
88+ const [ dismissedIds , setDismissedIds ] = useState < number [ ] > ( [ ] ) ;
8989
90+ const { data : announcementsResponse , error : announcementsError } = useGetAnnouncements ( ) ;
91+ const announcements = Array . isArray ( announcementsResponse )
92+ ? announcementsResponse
93+ : announcementsResponse ?. results ?? [ ] ;
94+
95+ const dismissAnnouncement = ( id : number ) => {
96+ setDismissedIds ( ( prev ) => [ ...prev , id ] ) ;
97+ } ;
9098
9199 return (
92100 < PageWrapper isDesktop = { isDesktop } >
101+ { /* Render Announcements */ }
102+ { announcementsError && (
103+ < div style = { { color : 'red' , marginBottom : '1rem' } } >
104+ Failed to load announcements: { announcementsError . message }
105+ </ div >
106+ ) }
93107
94- < PageTitle >
95- Surgeon Dashboard
96- </ PageTitle >
97- < DashboardWrapper >
98-
99- < div style = { { width : '100%' , zIndex : 1000 } } >
100- { ! isLoadingAnnouncements && announcementsData && (
101- < div style = { { marginBottom : '2rem' } } >
102- { ( Array . isArray ( announcementsData )
103- ? announcementsData
104- : announcementsData . results
105- )
106- . filter ( ( a ) => a ?. announcement_text )
108+ < PageTitle >
109+ Surgeon Dashboard
110+ </ PageTitle >
111+ < DashboardWrapper >
112+ { announcements
113+ . filter ( ( announcement ) => ! dismissedIds . includes ( announcement . id ) )
107114 . map ( ( announcement ) => (
108115 < div
109116 key = { announcement . id }
110117 style = { {
111118 border : '2px solid #0d629e' ,
112119 backgroundColor : '#d5e6f2' ,
120+ borderRadius : '6px' ,
113121 padding : '1rem' ,
114122 marginBottom : '1rem' ,
115- borderRadius : '4px' ,
116- whiteSpace : 'pre-wrap' ,
123+ position : 'relative' ,
117124 } }
118125 >
119- { announcement . announcement_text }
126+ < button
127+ onClick = { ( ) => dismissAnnouncement ( announcement . id ) }
128+ style = { {
129+ position : 'absolute' ,
130+ top : '6px' ,
131+ right : '10px' ,
132+ background : 'transparent' ,
133+ border : 'none' ,
134+ fontSize : '1.2rem' ,
135+ cursor : 'pointer' ,
136+ color : '#0d629e' ,
137+ } }
138+ aria-label = "Dismiss"
139+ >
140+ ×
141+ </ button >
142+ < div > { announcement . announcement_text } </ div >
120143 </ div >
121- ) ) }
122- </ div >
123- ) }
124- </ div >
125-
126-
144+ ) ) }
127145 < DashboardText >
128146 This is your personalized landing page with key insights on the episodes you have performed.
129147 </ DashboardText >
@@ -309,4 +327,4 @@ const LandingPage: React.FC = () => {
309327 ) ;
310328} ;
311329
312- export default LandingPage ;
330+ export default LandingPage ;
0 commit comments