UNPKG

@wenn/onb

Version:

onb-core

75 lines (61 loc) 1.64 kB
import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { reduxForm } from 'redux-form' import { saveCamunda, sendToCamunda } from '../../redux/actions/camunda.actions' const UserInfoPhoneHOC = Component => { class UserInfoPhone extends React.Component { constructor(props) { super(props) } componentDidMount() { sendlog("view_page"); } handleOnSend = e => { e.preventDefault() const { formData: { values }, viewName, saveCamunda, sendToCamunda } = this.props sendlog('event', { event_action: 'click', ...values }); saveCamunda(values) sendToCamunda(viewName) } render() { return ( <div> <Component {...this.props} onHandleOnSend={this.handleOnSend} /> </div> ) } } UserInfoPhone.proptTypes = { formData: PropTypes.object.isRequired, wording: PropTypes.object.isRequired, saveCamunda: PropTypes.func.isRequired, sendToCamunda: PropTypes.func.isRequired, viewName: PropTypes.string.isRequired } UserInfoPhone = reduxForm({ form: 'UserInfoPhone', destroyOnUnmount: false, forceUnregisterOnUnmount: true })(UserInfoPhone) const mapState = ({ settings: { wording, config }, form }, { viewName }) => ({ formData: form.UserInfoPhone ? form.UserInfoPhone : {}, wording: wording[viewName], config, viewName }) const mapDispatch = { saveCamunda, sendToCamunda } return connect( mapState, mapDispatch )(UserInfoPhone) } export default UserInfoPhoneHOC