Skip to content

Commit 5808225

Browse files
committed
Fix n.5 to announcements not rendering on staging site
1 parent b3d2ce7 commit 5808225

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

src/pages/LandingPage/LandingPage.tsx

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
PageWrapper,
1616
} from '../../common.style';
1717
import { useResponsiveLayout } from '../../hooks/useResponsiveSidebar';
18-
import { AnnouncementAPI, OwnedEpisodeAPI } from '../../models/apiTypes';
18+
import { OwnedEpisodeAPI } from '../../models/apiTypes';
1919
import { DashboardText, DashboardTextHeader, DashboardWrapper } from './LandingPage.style';
2020

2121

@@ -85,16 +85,8 @@ const LandingPage: React.FC = () => {
8585
history.push(`${urls.patients()}/${hospital_id}/${patient_id}${urls.episodes()}/${id}`);
8686
};
8787

88-
const { data: announcementsResponse, isLoading: announcementsLoading } = useGetAnnouncements();
89-
const [dismissedAnnouncements, setDismissedAnnouncements] = useState<number[]>([]);
88+
const { data: announcementsData, isLoading: isLoadingAnnouncements } = useGetAnnouncements();
9089

91-
const handleDismiss = (id: number) => {
92-
setDismissedAnnouncements((prev) => [...prev, id]);
93-
};
94-
95-
const visibleAnnouncements = announcementsResponse?.results?.filter(
96-
(a: AnnouncementAPI) => !dismissedAnnouncements.includes(a.id)
97-
) ?? [];
9890

9991
return (
10092
<PageWrapper isDesktop={isDesktop}>
@@ -105,38 +97,25 @@ const LandingPage: React.FC = () => {
10597
<DashboardWrapper>
10698

10799
<div style={{ width: '100%', zIndex: 1000 }}>
108-
{!announcementsLoading &&
109-
visibleAnnouncements.length > 0 &&
110-
visibleAnnouncements.map((announcement: AnnouncementAPI) => (
100+
{!isLoadingAnnouncements && announcementsData && announcementsData.results.length > 0 && (
101+
<div style={{ marginBottom: '2rem' }}>
102+
{announcementsData.results.map((announcement) => (
111103
<div
112104
key={announcement.id}
113105
style={{
114-
border: '1px solid #0d629e',
106+
border: '2px solid #0d629e',
115107
backgroundColor: '#d5e6f2',
116-
padding: '12px 16px',
117-
borderRadius: '8px',
118-
marginBottom: '16px',
119-
position: 'relative',
108+
padding: '1rem',
109+
marginBottom: '1rem',
110+
borderRadius: '4px',
111+
whiteSpace: 'pre-wrap', // preserves line breaks if any
120112
}}
121113
>
122-
<span>{announcement.announcement_text}</span>
123-
<button
124-
onClick={() => handleDismiss(announcement.id)}
125-
style={{
126-
position: 'absolute',
127-
top: '8px',
128-
right: '12px',
129-
background: 'transparent',
130-
border: 'none',
131-
fontWeight: 'bold',
132-
cursor: 'pointer',
133-
}}
134-
aria-label="Dismiss announcement"
135-
>
136-
×
137-
</button>
114+
{announcement.announcement_text}
138115
</div>
139116
))}
117+
</div>
118+
)}
140119
</div>
141120

142121

0 commit comments

Comments
 (0)