StickyFooter.js 1.88 KB
import React, { Component } from 'react';
import {NavLink} from 'react-router-dom';
import PropTypes from 'prop-types'

import * as SelectActionCreators from '../../actions/profilationSelect'
import { connect } from 'react-redux';

class StickyFooter extends Component {
  constructor(props){
    super(props)

    this.selectSolution=this.selectSolution.bind(this)
  }

  selectSolution(index){
    this.props.changeSolution(index,'isSelected','true')
  }


  render(){

    const footerCards=this.props.solutions.map((solution,index) => (
        <li key={index} className={solution.isActive? "isActive" :""}>
          <div>
            <p className="offers"><strong>{solution.name}</strong></p>
            <p className="price"><span></span><strong>{solution.price}</strong>/ mese + IVA</p>
            <NavLink to={`/activation`} activeClassName="active">
              <button className="btn btn__gray" onClick={() => this.selectSolution(index)}>Attiva Ora</button>
            </NavLink>
          </div>
        </li>
      ))

    return(
<div className="bigContainer stickySelect__button stickyNav isSticky">
      <ul>
         {footerCards}
      </ul>
    </div>
    )
  }
}

const mapStateToProps = state => {
  return {
  steps:state.ProfilationSelectReducer.steps,
  solutions:state.ProfilationSelectReducer.solutions
}};

const mapDispatchToProps = dispatch => ({
  updatePropValue: (prop,value,index,complete) => 
    dispatch(SelectActionCreators.changeValue(prop,value,index,complete)),
    changeSolution: (index,prop,value) => 
    dispatch(SelectActionCreators.changeSolution(index,prop,value)),
});

StickyFooter.propTypes = {
  solutions: PropTypes.array.isRequired,
  steps: PropTypes.array.isRequired,
  updatePropValue: PropTypes.func.isRequired,
     
}

export default connect(mapStateToProps, mapDispatchToProps)(StickyFooter);