@@ -8,7 +8,8 @@ import Timestamp from '@hig/timestamp';
88import axios from 'axios' ;
99
1010function 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