1
+ import React , { Component } from 'react' ;
2
+ import PropTypes from 'prop-types' ;
1
3
import { httpActions } from '@codetanzania/ewea-api-client' ;
2
4
import { Connect , reduxActions } from '@codetanzania/ewea-api-states' ;
3
- import PropTypes from 'prop-types' ;
4
- import React , { Component } from 'react' ;
5
- import isArray from 'lodash/isArray' ;
6
5
import { Modal , Col } from 'antd' ;
7
6
import { PlusOutlined } from '@ant-design/icons' ;
7
+ import isArray from 'lodash/isArray' ;
8
+ import get from 'lodash/get' ;
9
+
8
10
import Topbar from '../../components/Topbar' ;
9
- import EventGroupForm from './Form ' ;
11
+ import SettingForm from '../../components/SettingForm ' ;
10
12
import NotificationForm from '../../components/NotificationForm' ;
11
13
import ItemList from '../../components/List' ;
12
14
import ListItem from '../../components/ListItem' ;
13
15
import ListItemActions from '../../components/ListItemActions' ;
14
16
import { notifyError , notifySuccess , truncateString } from '../../util' ;
15
17
import './styles.css' ;
16
-
17
- /* constants */
18
+ /* http actions */
19
+ const {
20
+ getEventGroupsExportUrl,
21
+ getFocalPeople,
22
+ getJurisdictions,
23
+ getPartyGroups,
24
+ getRoles,
25
+ getAgencies,
26
+ } = httpActions ;
27
+ /* redux actions */
18
28
const {
19
29
getEventGroups,
20
30
openEventGroupForm,
@@ -24,28 +34,20 @@ const {
24
34
refreshEventGroups,
25
35
paginateEventGroups,
26
36
deleteEventGroup,
37
+ postEventGroup,
38
+ putEventGroup,
27
39
} = reduxActions ;
40
+ /* constants */
41
+ const { confirm } = Modal ;
28
42
const nameSpan = { xxl : 5 , xl : 5 , lg : 5 , md : 5 , sm : 6 , xs : 14 } ;
29
43
const codeSpan = { xxl : 2 , xl : 2 , lg : 2 , md : 2 , sm : 5 , xs : 4 } ;
30
44
const descriptionSpan = { xxl : 15 , xl : 15 , lg : 15 , md : 14 , sm : 9 , xs : 0 } ;
31
-
32
45
const headerLayout = [
33
46
{ ...nameSpan , header : 'Name' } ,
34
47
{ ...codeSpan , header : 'Code' } ,
35
48
{ ...descriptionSpan , header : 'Description' } ,
36
49
] ;
37
50
38
- const { confirm } = Modal ;
39
-
40
- const {
41
- getEventGroupsExportUrl,
42
- getFocalPeople,
43
- getJurisdictions,
44
- getPartyGroups,
45
- getRoles,
46
- getAgencies,
47
- } = httpActions ;
48
-
49
51
/**
50
52
* @class
51
53
* @name EventGroups
@@ -97,7 +99,7 @@ class EventGroups extends Component {
97
99
* @name searchEventGroups
98
100
* @description Search Event Groups List based on supplied filter word
99
101
*
100
- * @param {object } event - Event instance
102
+ * @param {object } event Event instance
101
103
*
102
104
* @version 0.1.0
103
105
* @since 0.1.0
@@ -131,6 +133,7 @@ class EventGroups extends Component {
131
133
* @since 0.1.0
132
134
*/
133
135
handleAfterCloseForm = ( ) => {
136
+ selectEventGroup ( null ) ;
134
137
this . setState ( { isEditForm : false } ) ;
135
138
} ;
136
139
@@ -242,7 +245,7 @@ class EventGroups extends Component {
242
245
loading,
243
246
page,
244
247
posting,
245
- eventType ,
248
+ eventGroup ,
246
249
showForm,
247
250
searchQuery,
248
251
total,
@@ -277,7 +280,6 @@ class EventGroups extends Component {
277
280
itemCount = { total }
278
281
loading = { loading }
279
282
// onFilter={this.openFiltersModal}
280
- // onNotify={this.openNotificationForm}
281
283
onShare = { this . handleShare }
282
284
onRefresh = { this . handleRefreshEventGroups }
283
285
generateExportUrl = { getEventGroupsExportUrl }
@@ -319,11 +321,11 @@ class EventGroups extends Component {
319
321
) }
320
322
>
321
323
{ /* eslint-disable react/jsx-props-no-spreading */ }
322
- < Col { ...nameSpan } > { item . strings . name . en } </ Col >
323
- < Col { ...codeSpan } > { item . strings . code } </ Col >
324
+ < Col { ...nameSpan } > { get ( item , ' strings.name.en' , 'N/A' ) } </ Col >
325
+ < Col { ...codeSpan } > { get ( item , ' strings.code' , 'N/A' ) } </ Col >
324
326
< Col { ...descriptionSpan } >
325
- < span title = { item . strings . description . en } >
326
- { truncateString ( item . strings . description . en , 120 ) }
327
+ < span title = { get ( item , ' strings.description.en' , '' ) } >
328
+ { truncateString ( get ( item , ' strings.description.en' , '' ) , 120 ) }
327
329
</ span >
328
330
</ Col >
329
331
{ /* eslint-enable react/jsx-props-no-spreading */ }
@@ -365,11 +367,12 @@ class EventGroups extends Component {
365
367
maskClosable = { false }
366
368
afterClose = { this . handleAfterCloseForm }
367
369
>
368
- < EventGroupForm
370
+ < SettingForm
371
+ setting = { eventGroup }
369
372
posting = { posting }
370
- isEditForm = { isEditForm }
371
- eventType = { eventType }
372
- onCancel = { this . closeEventGroupsForm }
373
+ onCancel = { this . handleAfterCloseForm }
374
+ onCreate = { postEventGroup }
375
+ onUpdate = { putEventGroup }
373
376
/>
374
377
</ Modal >
375
378
{ /* end create/edit form modal */ }
@@ -382,7 +385,7 @@ EventGroups.propTypes = {
382
385
loading : PropTypes . bool . isRequired ,
383
386
eventGroups : PropTypes . arrayOf ( PropTypes . shape ( { name : PropTypes . string } ) )
384
387
. isRequired ,
385
- eventType : PropTypes . shape ( { name : PropTypes . string } ) ,
388
+ eventGroup : PropTypes . shape ( { name : PropTypes . string } ) ,
386
389
page : PropTypes . number . isRequired ,
387
390
searchQuery : PropTypes . string ,
388
391
total : PropTypes . number . isRequired ,
@@ -391,13 +394,13 @@ EventGroups.propTypes = {
391
394
} ;
392
395
393
396
EventGroups . defaultProps = {
394
- eventType : null ,
397
+ eventGroup : null ,
395
398
searchQuery : undefined ,
396
399
} ;
397
400
398
401
export default Connect ( EventGroups , {
399
402
eventGroups : 'eventGroups.list' ,
400
- eventType : 'eventGroups.selected' ,
403
+ eventGroup : 'eventGroups.selected' ,
401
404
loading : 'eventGroups.loading' ,
402
405
posting : 'eventGroups.posting' ,
403
406
page : 'eventGroups.page' ,
0 commit comments