Skip to content

Commit d8a33a0

Browse files
authored
Merge pull request #462 from rvsia/fixNoNotifications
Fix no notifications for demo
2 parents d4f01dd + 4eec297 commit d8a33a0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-renderer-demo/src/app/src/components/notification-panel.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const getNotifications = () => {
4040
const query = `?orderBy="expired-at"&startAt="${new Date().toISOString()}"&limitToFirst=10`;
4141
return fetch(`https://data-driven-forms.firebaseio.com/notifications.json${query}`)
4242
.then((data) => data.json())
43-
.then((data) => data.filter(Boolean).sort((a, b) => b['created-at'].localeCompare(a['created-at'])) || []);
43+
.then((data) => (data ? data.filter(Boolean).sort((a, b) => b['created-at'].localeCompare(a['created-at'])) : []));
4444
};
4545

4646
const createNotificationId = (notification) => `${notification['created-at']}-${notification['expired-at']}`;
@@ -77,6 +77,14 @@ const NotificationPanel = ({ isOpen, onClose, anchorRef, setNewMessages }) => {
7777
{index < notifications.length - 1 ? <Divider variant="middle" /> : null}
7878
</React.Fragment>
7979
))}
80+
{notifications.length === 0 && (
81+
<ListItem alignItems="flex-start" className={classes.listItem}>
82+
<ListItemText
83+
secondary={<Markdown options={options}>No notifications</Markdown>}
84+
secondaryTypographyProps={{ color: 'textPrimary', component: 'div' }}
85+
/>
86+
</ListItem>
87+
)}
8088
</List>
8189
</Paper>
8290
</Grow>

0 commit comments

Comments
 (0)