Skip to content

Commit 9b6b0bb

Browse files
committed
refactor(stakeholder-group): migrate form to antv4
see #250
1 parent c24d6f5 commit 9b6b0bb

File tree

2 files changed

+28
-221
lines changed

2 files changed

+28
-221
lines changed

src/Stakeholders/StakeholderGroups/Form/index.js

-198
This file was deleted.

src/Stakeholders/StakeholderGroups/index.js

+28-23
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,28 @@ import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import { httpActions } from '@codetanzania/ewea-api-client';
44
import { Connect, reduxActions } from '@codetanzania/ewea-api-states';
5-
import isArray from 'lodash/isArray';
65
import { Modal, Col } from 'antd';
76
import { PlusOutlined } from '@ant-design/icons';
7+
import isArray from 'lodash/isArray';
8+
89
import Topbar from '../../components/Topbar';
9-
import PartyGroupForm from './Form';
10+
import SettingForm from '../../components/SettingForm';
1011
import NotificationForm from '../../components/NotificationForm';
1112
import ItemList from '../../components/List';
1213
import ListItem from '../../components/ListItem';
1314
import ListItemActions from '../../components/ListItemActions';
1415
import { notifyError, notifySuccess, truncateString } from '../../util';
1516
import './styles.css';
1617

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 */
3019
const {
3120
getPartyGroupsExportUrl,
3221
getFocalPeople,
3322
getJurisdictions,
3423
getRoles,
3524
getAgencies,
3625
} = httpActions;
26+
/* redux actions */
3727
const {
3828
getPartyGroups,
3929
openPartyGroupForm,
@@ -43,8 +33,21 @@ const {
4333
refreshPartyGroups,
4434
paginatePartyGroups,
4535
deletePartyGroup,
36+
postPartyGroup,
37+
putPartyGroup,
4638
} = reduxActions;
4739

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+
4851
/**
4952
* @class
5053
* @name PartyGroups
@@ -96,7 +99,7 @@ class PartyGroups extends Component {
9699
* @name searchPartyGroups
97100
* @description Search Stakeholder Groups List based on supplied filter word
98101
*
99-
* @param {object} party - Party instance
102+
* @param {object} party Party instance
100103
*
101104
* @version 0.1.0
102105
* @since 0.1.0
@@ -130,6 +133,7 @@ class PartyGroups extends Component {
130133
* @since 0.1.0
131134
*/
132135
handleAfterCloseForm = () => {
136+
selectPartyGroup(null);
133137
this.setState({ isEditForm: false });
134138
};
135139

@@ -241,7 +245,7 @@ class PartyGroups extends Component {
241245
loading,
242246
page,
243247
posting,
244-
partyType,
248+
partyGroup,
245249
showForm,
246250
searchQuery,
247251
total,
@@ -366,11 +370,12 @@ class PartyGroups extends Component {
366370
maskClosable={false}
367371
afterClose={this.handleAfterCloseForm}
368372
>
369-
<PartyGroupForm
373+
<SettingForm
374+
setting={partyGroup}
370375
posting={posting}
371-
isEditForm={isEditForm}
372-
partyType={partyType}
373376
onCancel={this.closePartyGroupsForm}
377+
onCreate={postPartyGroup}
378+
onUpdate={putPartyGroup}
374379
/>
375380
</Modal>
376381
{/* end create/edit form modal */}
@@ -383,7 +388,7 @@ PartyGroups.propTypes = {
383388
loading: PropTypes.bool.isRequired,
384389
partyGroups: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string }))
385390
.isRequired,
386-
partyType: PropTypes.shape({ name: PropTypes.string }),
391+
partyGroup: PropTypes.shape({ name: PropTypes.string }),
387392
page: PropTypes.number.isRequired,
388393
searchQuery: PropTypes.string,
389394
total: PropTypes.number.isRequired,
@@ -392,13 +397,13 @@ PartyGroups.propTypes = {
392397
};
393398

394399
PartyGroups.defaultProps = {
395-
partyType: null,
400+
partyGroup: null,
396401
searchQuery: undefined,
397402
};
398403

399404
export default Connect(PartyGroups, {
400405
partyGroups: 'partyGroups.list',
401-
partyType: 'partyGroups.selected',
406+
partyGroup: 'partyGroups.selected',
402407
loading: 'partyGroups.loading',
403408
posting: 'partyGroups.posting',
404409
page: 'partyGroups.page',

0 commit comments

Comments
 (0)