Skip to content

Commit 73e4b58

Browse files
feat: localized no-notifications message (#52)
0.0.29 0.0.30 feat: localized no-notifications message Co-authored-by: enzo707 <[email protected]>
1 parent f587d68 commit 73e4b58

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dynamods/notifications-center",
3-
"version": "0.0.28",
3+
"version": "0.0.29",
44
"description": "Notification center maintained by Dynamo Team@Autodesk",
55
"author": "Autodesk Inc.",
66
"license": "MIT",

src/App.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import Timestamp from '@hig/timestamp';
88
import axios from 'axios';
99

1010
function App() {
11-
const [APIData, setAPIData] = useState({ loaded: false, notifications: [], title: 'Notifications', bottomButtonText: 'Mark all as read' });
11+
const [APIData, setAPIData] = useState({ loaded: false, notifications: [], title: 'Notifications', bottomButtonText: 'Mark all as read',
12+
noNotificationsTexts: { title:'', msg:''} });
1213
const forceRender = useReRender();
1314

1415
useEffect(() => {
@@ -26,6 +27,7 @@ function App() {
2627
} else {
2728
window.setNotifications = setNotifications;
2829
window.setTitle = setTitle;
30+
window.setNoNotificationsTexts = setNoNotificationsTexts;
2931
window.setBottomButtonText = setBottomButtonText;
3032
window.setPopupHeight = setPopupHeight;
3133
}
@@ -46,10 +48,9 @@ function App() {
4648
let notificationsData = parseNotifications(notifications);
4749
setAPIData(prevState => {
4850
return {
51+
...prevState,
4952
loaded: true,
5053
notifications: notificationsData,
51-
title: prevState.title,
52-
bottomButtonText: prevState.bottomButtonText
5354
};
5455
});
5556
};
@@ -109,20 +110,25 @@ function App() {
109110
const setTitle = (titleText) => {
110111
setAPIData(prevState => {
111112
return {
112-
loaded: prevState.loaded,
113-
notifications: prevState.notifications,
114-
title: titleText,
115-
bottomButtonText: prevState.bottomButtonText
113+
...prevState,
114+
title: titleText
116115
};
117116
});
118117
};
119-
118+
119+
const setNoNotificationsTexts = (texts) => {
120+
setAPIData(prevState => {
121+
return {
122+
...prevState,
123+
noNotificationsTexts: JSON.parse(texts)
124+
};
125+
});
126+
};
127+
120128
const setBottomButtonText = (buttonText) => {
121129
setAPIData(prevState => {
122130
return {
123-
loaded: prevState.loaded,
124-
notifications: prevState.notifications,
125-
title: prevState.title,
131+
...prevState,
126132
bottomButtonText: buttonText
127133
};
128134
});
@@ -137,8 +143,8 @@ function App() {
137143
markAsRead={markAsRead}
138144
notifications={APIData.notifications}
139145
emptyImage={<EmptyStateArchiver />}
140-
emptyTitle={'No notifications'}
141-
emptyMessage={'You currently have no notifications. New notifications will appear above'}
146+
emptyTitle={APIData.noNotificationsTexts.title}
147+
emptyMessage={APIData.noNotificationsTexts.msg}
142148
onNotificationChanged={notificationChanged}
143149
/>
144150
: null;

0 commit comments

Comments
 (0)