@@ -2,38 +2,28 @@ import React, { Component } from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import { httpActions } from '@codetanzania/ewea-api-client' ;
4
4
import { Connect , reduxActions } from '@codetanzania/ewea-api-states' ;
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
+
8
9
import Topbar from '../../components/Topbar' ;
9
- import PartyGroupForm from './Form ' ;
10
+ import SettingForm from '../../components/SettingForm ' ;
10
11
import NotificationForm from '../../components/NotificationForm' ;
11
12
import ItemList from '../../components/List' ;
12
13
import ListItem from '../../components/ListItem' ;
13
14
import ListItemActions from '../../components/ListItemActions' ;
14
15
import { notifyError , notifySuccess , truncateString } from '../../util' ;
15
16
import './styles.css' ;
16
17
17
- /* constants */
18
- const nameSpan = { xxl : 5 , xl : 5 , lg : 5 , md : 5 , sm : 6 , xs : 14 } ;
19
- const codeSpan = { xxl : 2 , xl : 2 , lg : 2 , md : 2 , sm : 5 , xs : 4 } ;
20
- const descriptionSpan = { xxl : 15 , xl : 15 , lg : 15 , md : 14 , sm : 9 , xs : 0 } ;
21
-
22
- const headerLayout = [
23
- { ...nameSpan , header : 'Name' } ,
24
- { ...codeSpan , header : 'Code' } ,
25
- { ...descriptionSpan , header : 'Description' } ,
26
- ] ;
27
-
28
- const { confirm } = Modal ;
29
-
18
+ /* http actions */
30
19
const {
31
20
getPartyGroupsExportUrl,
32
21
getFocalPeople,
33
22
getJurisdictions,
34
23
getRoles,
35
24
getAgencies,
36
25
} = httpActions ;
26
+ /* redux actions */
37
27
const {
38
28
getPartyGroups,
39
29
openPartyGroupForm,
@@ -43,8 +33,21 @@ const {
43
33
refreshPartyGroups,
44
34
paginatePartyGroups,
45
35
deletePartyGroup,
36
+ postPartyGroup,
37
+ putPartyGroup,
46
38
} = reduxActions ;
47
39
40
+ /* constants */
41
+ const { confirm } = Modal ;
42
+ const nameSpan = { xxl : 5 , xl : 5 , lg : 5 , md : 5 , sm : 6 , xs : 14 } ;
43
+ const codeSpan = { xxl : 2 , xl : 2 , lg : 2 , md : 2 , sm : 5 , xs : 4 } ;
44
+ const descriptionSpan = { xxl : 15 , xl : 15 , lg : 15 , md : 14 , sm : 9 , xs : 0 } ;
45
+ const headerLayout = [
46
+ { ...nameSpan , header : 'Name' } ,
47
+ { ...codeSpan , header : 'Code' } ,
48
+ { ...descriptionSpan , header : 'Description' } ,
49
+ ] ;
50
+
48
51
/**
49
52
* @class
50
53
* @name PartyGroups
@@ -96,7 +99,7 @@ class PartyGroups extends Component {
96
99
* @name searchPartyGroups
97
100
* @description Search Stakeholder Groups List based on supplied filter word
98
101
*
99
- * @param {object } party - Party instance
102
+ * @param {object } party Party instance
100
103
*
101
104
* @version 0.1.0
102
105
* @since 0.1.0
@@ -130,6 +133,7 @@ class PartyGroups extends Component {
130
133
* @since 0.1.0
131
134
*/
132
135
handleAfterCloseForm = ( ) => {
136
+ selectPartyGroup ( null ) ;
133
137
this . setState ( { isEditForm : false } ) ;
134
138
} ;
135
139
@@ -241,7 +245,7 @@ class PartyGroups extends Component {
241
245
loading,
242
246
page,
243
247
posting,
244
- partyType ,
248
+ partyGroup ,
245
249
showForm,
246
250
searchQuery,
247
251
total,
@@ -366,11 +370,12 @@ class PartyGroups extends Component {
366
370
maskClosable = { false }
367
371
afterClose = { this . handleAfterCloseForm }
368
372
>
369
- < PartyGroupForm
373
+ < SettingForm
374
+ setting = { partyGroup }
370
375
posting = { posting }
371
- isEditForm = { isEditForm }
372
- partyType = { partyType }
373
376
onCancel = { this . closePartyGroupsForm }
377
+ onCreate = { postPartyGroup }
378
+ onUpdate = { putPartyGroup }
374
379
/>
375
380
</ Modal >
376
381
{ /* end create/edit form modal */ }
@@ -383,7 +388,7 @@ PartyGroups.propTypes = {
383
388
loading : PropTypes . bool . isRequired ,
384
389
partyGroups : PropTypes . arrayOf ( PropTypes . shape ( { name : PropTypes . string } ) )
385
390
. isRequired ,
386
- partyType : PropTypes . shape ( { name : PropTypes . string } ) ,
391
+ partyGroup : PropTypes . shape ( { name : PropTypes . string } ) ,
387
392
page : PropTypes . number . isRequired ,
388
393
searchQuery : PropTypes . string ,
389
394
total : PropTypes . number . isRequired ,
@@ -392,13 +397,13 @@ PartyGroups.propTypes = {
392
397
} ;
393
398
394
399
PartyGroups . defaultProps = {
395
- partyType : null ,
400
+ partyGroup : null ,
396
401
searchQuery : undefined ,
397
402
} ;
398
403
399
404
export default Connect ( PartyGroups , {
400
405
partyGroups : 'partyGroups.list' ,
401
- partyType : 'partyGroups.selected' ,
406
+ partyGroup : 'partyGroups.selected' ,
402
407
loading : 'partyGroups.loading' ,
403
408
posting : 'partyGroups.posting' ,
404
409
page : 'partyGroups.page' ,
0 commit comments