UNPKG

@wenn/onb

Version:

onb-core

84 lines (72 loc) 1.71 kB
import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { saveCamunda, sendToCamunda } from '../../redux/actions/camunda.actions'; const ConfirmationHOC = Component => { class Confirmation extends React.Component { constructor() { super(); this.state = {}; } componentDidMount() { sendlog('view_page'); } handleOnSend = e => { e.preventDefault(); const { viewName, saveCamunda, sendToCamunda } = this.props; const data = {}; sendlog('event', { event_action: 'click' }); saveCamunda(data); sendToCamunda(viewName); }; render() { return ( <Component {...this.props} onHandleOnSend={e => this.handleOnSend(e)} /> ); } } Confirmation.proptTypes = { formData: PropTypes.object.isRequired, wording: PropTypes.object.isRequired, saveCamunda: PropTypes.func.isRequired, sendToCamunda: PropTypes.func.isRequired, viewName: PropTypes.string.isRequired }; const mapState = ( { settings: { wording, config, theme, utils: { BANKS } }, form, camunda: { product, lastname, firstname, country } }, { viewName } ) => ({ formData: form, wording: wording[viewName], config, viewName, theme, product, BANKS: BANKS[country.value], username: lastname && firstname && `${lastname && lastname.value}, ${firstname && firstname.value}` }); const mapDispatch = { saveCamunda, sendToCamunda }; return connect( mapState, mapDispatch )(Confirmation); }; export default ConfirmationHOC;