/** * * SettingsPage */ import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators, compose } from 'redux'; import { createStructuredSelector } from 'reselect'; import cn from 'classnames'; import { get } from 'lodash'; import PropTypes from 'prop-types'; import { onChange } from 'containers/App/actions'; import { makeSelectSchema } from 'containers/App/selectors'; import PluginHeader from 'components/PluginHeader'; import Input from 'components/InputsIndex'; import Block from 'components/Block'; import injectReducer from 'utils/injectReducer'; import injectSaga from 'utils/injectSaga'; import reducer from './reducer'; import saga from './saga'; import makeSelectSettingsPage from './selectors'; import styles from './styles.scss'; import forms from './forms.json'; class SettingsPage extends React.PureComponent { getPluginHeaderActions = () => ( [ { label: 'content-manager.popUpWarning.button.cancel', kind: 'secondary', onClick: () => {}, type: 'button', }, { kind: 'primary', label: 'content-manager.containers.Edit.submit', onClick: () => {}, type: 'submit', }, ] ); getValue = (input) => { const { schema: { generalSettings } } = this.props; const value = get(generalSettings, input.name.split('.')[1], input.type === 'toggle' ? false : 10); return input.type === 'toggle' ? value : value.toString(); } render() { return (
e.preventDefault()} className={styles.ctmForm}>
{forms.inputs.map(input => { return ( ); })}
); } } SettingsPage.defaultProps = {}; SettingsPage.propTypes = { onChange: PropTypes.func.isRequired, schema: PropTypes.object.isRequired, }; const mapDispatchToProps = (dispatch) => ( bindActionCreators( { onChange, }, dispatch, ) ); const mapStateToProps = createStructuredSelector({ schema: makeSelectSchema(), settingsPage: makeSelectSettingsPage(), }); const withConnect = connect(mapStateToProps, mapDispatchToProps); const withReducer = injectReducer({ key: 'settingsPage', reducer }); const withSaga = injectSaga({ key: 'settingsPage', saga }); export default compose( withReducer, withSaga, withConnect, )(SettingsPage);