/**
*
* PopUpForm
*
*/
import React from 'react';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import { get, isObject, includes, map, take, takeRight } from 'lodash';
// Translations
import en from 'translations/en.json';
import Input from 'components/Input';
import styles from './styles.scss';
class PopUpForm extends React.Component { // eslint-disable-line react/prefer-stateless-function
renderButton = () => {
if (this.props.showLoader) {
return (
);
}
return (
);
}
renderForm = () => {
const { dataToEdit, values } = this.props;
if (this.props.settingType === 'providers') {
return (
);
}
const form = Object.keys(values.options || {}).reduce((acc, current) => {
if (isObject(get(values, ['options', current]))) {
return Object.keys(get(values, ['options', current], {}))
.reduce((acc, curr) => {
acc.push(`options.${current}.${curr}`);
return acc;
}, []).concat(acc);
} else {
acc.push(`options.${current}`);
}
return acc;
}, []);
return (
);
}
render() {
const { actionType, dataToEdit, display, settingType } = this.props.values;
let header = {dataToEdit};
if (actionType) {
header = ;
}
if (display && en[display]) {
header = ;
}
return (
);
}
}
PopUpForm.contextTypes = {
unsetDataToEdit: PropTypes.func.isRequired,
};
PopUpForm.defaultProps = {
settingType: 'providers',
showLoader: false,
};
PopUpForm.propTypes = {
actionType: PropTypes.string.isRequired,
dataToEdit: PropTypes.string.isRequired,
isOpen: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
settingType: PropTypes.string,
showLoader: PropTypes.bool,
values: PropTypes.object.isRequired,
};
export default PopUpForm;