@@ -5,7 +5,6 @@ import { Connect, reduxActions } from '@codetanzania/ewea-api-states';
5
5
import { Modal , Col } from 'antd' ;
6
6
import { PlusOutlined } from '@ant-design/icons' ;
7
7
import get from 'lodash/get' ;
8
- import isArray from 'lodash/isArray' ;
9
8
import Topbar from '../components/Topbar' ;
10
9
import UnitForm from './Form' ;
11
10
import NotificationForm from '../components/NotificationForm' ;
@@ -181,6 +180,37 @@ class UnitList extends Component {
181
180
) ;
182
181
} ;
183
182
183
+ /**
184
+ * @function handleListShare
185
+ * @name handleListShare
186
+ * @description Handle list sharing
187
+ * @param {object[] } items List of items
188
+ * @version 0.1.0
189
+ * @since 0.1.0
190
+ */
191
+ handleListShare = ( items ) => {
192
+ const itemList = [ ] . concat ( items ) ;
193
+
194
+ const notificationSubject = 'List of Units' ;
195
+ const notificationBody = itemList
196
+ . map ( ( item ) => {
197
+ const itemName = get ( item , 'strings.name.en' , 'N/A' ) ;
198
+ const itemAbbreviation = get ( item , 'strings.abbreviation.en' , 'N/A' ) ;
199
+ const itemSymbol = get ( item , 'strings.symbol' , 'N/A' ) ;
200
+ const itemDescription = get ( item , 'strings.description.en' , 'N/A' ) ;
201
+ const body = `Name: ${ itemName } \nAbbreviation: ${ itemAbbreviation } \nSymbol: ${ itemSymbol } \nDescription: ${ itemDescription } \n` ;
202
+ return body ;
203
+ } )
204
+ . join ( '\n' ) ;
205
+ const showNotificationForm = true ;
206
+
207
+ this . setState ( {
208
+ notificationSubject,
209
+ notificationBody,
210
+ showNotificationForm,
211
+ } ) ;
212
+ } ;
213
+
184
214
/**
185
215
* @function handleItemEdit
186
216
* @name handleItemEdit
@@ -223,52 +253,22 @@ class UnitList extends Component {
223
253
} ) ;
224
254
} ;
225
255
226
- /**
227
- * @function
228
- * @name handleListShare
229
- * @description Handle share multiple event Indicators
230
- *
231
- * @param {object[]| object } units event Indicators list to be shared
232
- *
233
- * @version 0.1.0
234
- * @since 0.1.0
235
- */
236
- handleListShare = ( units ) => {
237
- let message = '' ;
238
- if ( isArray ( units ) ) {
239
- const unitList = units . map (
240
- ( unit ) =>
241
- `Name: ${ unit . strings . name . en } \nDescription: ${
242
- // eslint-disable-line
243
- unit . strings . description . en
244
- } \n`
245
- ) ;
246
-
247
- message = unitList . join ( '\n\n\n' ) ;
248
- } else {
249
- message = `Name: ${ units . strings . name . en } \nDescription: ${
250
- // eslint-disable-line
251
- units . strings . description . en
252
- } \n`;
253
- }
254
-
255
- this . setState ( { notificationBody : message , showNotificationForm : true } ) ;
256
- } ;
257
-
258
256
/**
259
257
* @function handleItemShare
260
258
* @name handleItemShare
261
- * @description Handle list item edit
259
+ * @description Handle list item sharing
262
260
* @param {object } item List item
263
261
* @version 0.1.0
264
262
* @since 0.1.0
265
263
*/
266
264
handleItemShare = ( item ) => {
267
265
const itemName = get ( item , 'strings.name.en' , 'N/A' ) ;
266
+ const itemAbbreviation = get ( item , 'strings.abbreviation.en' , 'N/A' ) ;
267
+ const itemSymbol = get ( item , 'strings.symbol' , 'N/A' ) ;
268
268
const itemDescription = get ( item , 'strings.description.en' , 'N/A' ) ;
269
269
270
- const notificationSubject = 'Unit Details ' ;
271
- const notificationBody = `Name: ${ itemName } \nDescription: ${ itemDescription } \n` ;
270
+ const notificationSubject = 'List of Units ' ;
271
+ const notificationBody = `Name: ${ itemName } \nAbbreviation: ${ itemAbbreviation } \nSymbol: ${ itemSymbol } \ nDescription: ${ itemDescription } \n` ;
272
272
const showNotificationForm = true ;
273
273
274
274
this . setState ( {
0 commit comments