import React, { Component } from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { Trans } from 'react-i18next'; import * as actionCreators from '../../actions/install'; import { INSTALL_FIRST_STEP, INSTALL_TOTAL_STEPS } from '../../helpers/constants'; class Controls extends Component { nextStep = () => { if (this.props.step < INSTALL_TOTAL_STEPS) { this.props.nextStep(); } } prevStep = () => { if (this.props.step > INSTALL_FIRST_STEP) { this.props.prevStep(); } } renderButtons(step) { switch (step) { case 1: return ( ); case 2: case 3: return (
); case 4: return (
); case 5: return ( ); default: return false; } } render() { return (
{this.renderButtons(this.props.step)}
); } } Controls.propTypes = { step: PropTypes.number.isRequired, nextStep: PropTypes.func, prevStep: PropTypes.func, pristine: PropTypes.bool, submitting: PropTypes.bool, }; const mapStateToProps = (state) => { const { step } = state.install; const props = { step }; return props; }; export default connect( mapStateToProps, actionCreators, )(Controls);