SessionExpired.js 4.33 KB
import React, { Component } from 'react'
import ReactModal from 'react-modal';

import {NavLink} from 'react-router-dom';

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



import endActivation from './img/end_activation.svg'

/*
<div className="Modal Modal-mask modal_repower Modal--save isOpen">
      <div className="Modal-wrapper">
      <div className="Modal-container" >
*/
class SessionExpired extends Component {


  constructor(props) {
    super(props);

    this.state = {
      email:'',
      name:'',
      privacy:true,
      buttonDisabled: true
    };
    this.handleChange = this.handleChange.bind(this);
    this.handleCheckbox = this.handleCheckbox.bind(this);

    this.redirect=this.redirect.bind(this)
  }

  redirect(){
    window.location.href='http://www.repower.com'
  }

  handleCheckbox(e){
    const target = e.currentTarget;
   
    this.form.validateFields(target);

    
    const checkbox= !this.state.privacy
    const disable= !checkbox
    this.setState({
      name:this.state.name,
      email: this.state.email,
      privacy: checkbox,
      buttonDisabled: disable
    });

    console.log('isValid',this.state)
  }


  handleChange(e) {
    const target = e.currentTarget;
   
    this.form.validateFields(target);
   
    const isValid=this.form.fieldsStore.fields.email.warnings.size===0 && 
                  this.form.fieldsStore.fields.email.errors.size===0 &&
                  this.state.email!=='' &&
                  this.form.fieldsStore.fields.name.warnings.size===0 && 
                  this.form.fieldsStore.fields.name.errors.size===0 &&
                  this.state.name!==''
    const checkbox= this.state.privacy
    console.log('isValid',this.form.fieldsStore.fields)
    const disable= !isValid
    this.setState({
      privacy: checkbox,
      [target.name]: target.value,
      buttonDisabled: disable
    });
    console.log('isValid',this.state)
  }

  render(){
    
    return(
      <ReactModal
          isOpen={true}
          onRequestClose={() => this.props.hideModal()}
          portalClassName='modal modal-mask modal_repower modal_repower__contact modal_repower__contact_confirm modal-confirm isOpen'
          overlayClassName='modal-wrapper'
          className='modal-container'
        >

          
        
          <div className="close_modal" onClick={()=>this.props.updateStoreValue('modalOpen',[])}><img src="https://d33wubrfki0l68.cloudfront.net/c0553300c767c895ee4900759828af6476c3e9e9/55953/img/closed_modal.svg" alt="" /></div>
          
          <div  class=" modal-header">
            <img src={endActivation} alt="" />
            <h3> Processo di attivazione scaduto</h3>
           
          </div>

          <div class="modal-body">

          <p class="modal-description">Sono passati più di 30 giorni e la soluzione energetica che hai
          iniziato ad attivare non è più valida. Puoi aggiornare la soluzione per la tua attività e riprendere l'attivazione.</p>
            
          </div>

         

          

          
          <div class="modal-footer">
            
            <NavLink to={`/`} activeClassName="active">
                            <button className="btn btn__red"
                                   onClick={() => this.props.hideModal()}>Aggiorna soluzione
                            </button>
                        </NavLink>
          </div>
        
        
        </ReactModal>
      )
  }
}

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

const mapDispatchToProps = dispatch => ({
  updatePropValue: (prop,value,index,complete) => 
    dispatch(SelectActionCreators.changeValue(prop,value,index,complete)),
  updateStoreValue: (prop,value) => 
    dispatch(SelectActionCreators.changeProp(prop,value)),
    hideModal: () => 
    dispatch(SelectActionCreators.hideModal()),
    showModal: (modalName) => 
    dispatch(SelectActionCreators.showModal(modalName)),
    
});

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