@@ -55,7 +55,10 @@ const headerLayout = [
55
55
/* messages */
56
56
const MESSAGE_LIST_REFRESH_SUCCESS = 'Units were refreshed successfully' ;
57
57
const MESSAGE_LIST_REFRESH_ERROR =
58
- 'An Error occurred while refreshing Units, please try again!' ;
58
+ 'An Error occurred while refreshing Units, Please try again!' ;
59
+ const MESSAGE_ITEM_ARCHIVE_SUCCESS = 'Unit was archived successfully' ;
60
+ const MESSAGE_ITEM_ARCHIVE_ERROR =
61
+ 'An error occurred while archiving Unit, Please try again!' ;
59
62
60
63
/**
61
64
* @function UnitList
@@ -96,6 +99,7 @@ class UnitList extends Component {
96
99
this . state = {
97
100
isEditForm : false ,
98
101
showNotificationForm : false ,
102
+ notificationSubject : undefined ,
99
103
notificationBody : undefined ,
100
104
} ;
101
105
}
@@ -202,19 +206,18 @@ class UnitList extends Component {
202
206
*/
203
207
204
208
showArchiveConfirm = ( item ) => {
209
+ const itemId = get ( item , '_id' ) ;
210
+ const itemName = get ( item , 'strings.name.en' , 'N/A' ) ;
205
211
confirm ( {
206
- title : `Are you sure you want to archive ${ item . strings . name . en } ?` ,
212
+ title : `Are you sure you want to archive ${ itemName } ?` ,
207
213
okText : 'Yes' ,
208
214
okType : 'danger' ,
209
215
cancelText : 'No' ,
210
216
onOk ( ) {
211
217
deleteUnit (
212
- item . _id , // eslint-disable-line
213
- ( ) => notifySuccess ( 'Unit was archived successfully' ) ,
214
- ( ) =>
215
- notifyError (
216
- 'An error occurred while archiving Unit, Please contact your system Administrator'
217
- )
218
+ itemId ,
219
+ ( ) => notifySuccess ( MESSAGE_ITEM_ARCHIVE_SUCCESS ) ,
220
+ ( ) => notifyError ( MESSAGE_ITEM_ARCHIVE_ERROR )
218
221
) ;
219
222
} ,
220
223
} ) ;
@@ -261,12 +264,18 @@ class UnitList extends Component {
261
264
* @since 0.1.0
262
265
*/
263
266
handleItemShare = ( item ) => {
264
- const message = `Name: ${ item . strings . name . en } \nDescription: ${
265
- // eslint-disable-line
266
- item . strings . description . en
267
- } \n`;
267
+ const itemName = get ( item , 'strings.name.en' , 'N/A' ) ;
268
+ const itemDescription = get ( item , 'strings.description.en' , 'N/A' ) ;
268
269
269
- this . setState ( { notificationBody : message , showNotificationForm : true } ) ;
270
+ const notificationSubject = 'Unit Details' ;
271
+ const notificationBody = `Name: ${ itemName } \nDescription: ${ itemDescription } \n` ;
272
+ const showNotificationForm = true ;
273
+
274
+ this . setState ( {
275
+ notificationSubject,
276
+ notificationBody,
277
+ showNotificationForm,
278
+ } ) ;
270
279
} ;
271
280
272
281
/**
@@ -291,6 +300,7 @@ class UnitList extends Component {
291
300
* @since 0.1.0
292
301
*/
293
302
render ( ) {
303
+ // props
294
304
const {
295
305
units,
296
306
loading,
@@ -301,7 +311,14 @@ class UnitList extends Component {
301
311
searchQuery,
302
312
total,
303
313
} = this . props ;
304
- const { isEditForm, showNotificationForm, notificationBody } = this . state ;
314
+
315
+ // states
316
+ const {
317
+ isEditForm,
318
+ showNotificationForm,
319
+ notificationSubject,
320
+ notificationBody,
321
+ } = this . state ;
305
322
306
323
return (
307
324
< >
@@ -415,6 +432,7 @@ class UnitList extends Component {
415
432
onSearchGroups = { getPartyGroups }
416
433
onSearchAgencies = { getAgencies }
417
434
onSearchRoles = { getRoles }
435
+ subject = { notificationSubject }
418
436
body = { notificationBody }
419
437
onCancel = { this . handleNotificationFormClose }
420
438
/>
0 commit comments