/** * * PopUpForm * */ import React from 'react'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { FormattedMessage } from 'react-intl'; import PropTypes from 'prop-types'; import { capitalize, get, findIndex, isArray, isObject, includes, map, tail, 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 state = { enabled: false }; handleChange = (e) => { this.setState({ enabled: e.target.value }); this.props.onChange(e); } renderForm = () => { const { dataToEdit, settingType, values } = this.props; const form = Object.keys(values.options || values || {}).reduce((acc, current) => { const path = settingType === 'email-templates' ? ['options', current] : [ current ]; const name = settingType === 'email-templates' ? 'options.' : ''; if (isObject(get(values, path)) && !isArray(get(values, path))) { return Object.keys(get(values, path, {})) .reduce((acc, curr) => { acc.push(`${name}${current}.${curr}`); return acc; }, []).concat(acc); } else if (current !== 'icon' && current !== 'scope'){ acc.push(`${name}${current}`); } return acc; }, []); if (settingType === 'providers') { return (