PropTypes and refactoring

This commit is contained in:
2021-05-04 21:59:52 -05:00
parent ace51f61d1
commit 3227f289f1
7 changed files with 260 additions and 231 deletions

View File

@@ -1,26 +1,17 @@
import React from 'react';
import './ConfigurationItem.css';
import CheckBox from '../../../components/UI/CheckBox/CheckBox';
import { connect } from 'react-redux';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { notifyError, notifyInfo } from '../../../redux/actions/error_actions';
import settings from '../../../assets/settings';
import DropDown from '../../../components/UI/DropDown/DropDown';
import HostList from '../../HostList/HostList';
import Password from '../../../containers/UI/Password/Password';
import PropTypes from 'prop-types';
import settings from '../../../assets/settings';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { connect } from 'react-redux';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { notifyError, notifyInfo } from '../../../redux/actions/error_actions';
const mapDispatchToProps = (dispatch) => {
return {
notifyError: (msg) => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
};
};
export default connect(
null,
mapDispatchToProps
)((props) => {
const ConfigurationItem = (props) => {
const handleChanged = (e) => {
const target = e.target;
if (target.type === 'checkbox') {
@@ -261,4 +252,26 @@ export default connect(
</table>
</div>
);
});
};
const mapDispatchToProps = (dispatch) => {
return {
notifyError: (msg) => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
};
};
ConfigurationItem.propTypes = {
autoFocus: PropTypes.bool,
changed: PropTypes.func.isRequired,
grouping: PropTypes.string,
items: PropTypes.array,
label: PropTypes.string,
notifyError: PropTypes.func.isRequired,
notifyInfo: PropTypes.func.isRequired,
readOnly: PropTypes.bool,
template: PropTypes.object.isRequired,
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.number]),
};
export default connect(null, mapDispatchToProps)(ConfigurationItem);