title: Multiple Registration Form with redux and react
body: <p>I have been trying to develop a dashboard form similiar to airbnb listing form for understanding more deeply about react redux but i am stuck in the middle of my project. I have a multiple form where when user clicks on continue button the user will get another form to fill and so on and if user clicks on back button the user will get form of one step back with previously filled values. I could not decide what should i do for this. Do i have to create a object in action as listingName . summary, name, email etc as empty value and update it with reducer using Object.assign() or what. Till now i could only develop like when user clicks on personal tab a form related to personal information is shown and when user clicks on basic tab, a form related to basic information is shown. I want all form data to be send to server at last submit. What should i do now ? Do i use increment and decrement action for the continue and back button and use submit action on the last form button ? Could you please provide me an idea ? </p>
  
  <p><a href="https://i.stack.imgur.com/mWwjY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mWwjY.png" alt="dashboard form"></a> </p>
  
  <p>Here's my code </p>
  
  <p><strong>actions/index.js</strong></p>
  
  <pre><code>export function selectForm(form){
    return{
      type: 'FORM_SELECTED',
      payload: form
    };
  
  }
  </code></pre>
  
  <p><strong>reducers/reducer_active_form.js</strong></p>
  
  <pre><code>export default function(state=null, action){
    let newState = Object.assign({},state);
    switch(action.type){
      case 'FORM_SELECTED':
        return action.payload;
    }
    return state;
  }
  </code></pre>
  
  <p><strong>reducers/reducer_form_option.js</strong></p>
  
  <pre><code>export default function(){
    return[
      { option: 'Personal Information', id:1},
      { option: 'Basic Information', id:2 },
      { option: 'Description', id:3},
      { option: 'Location', id:4},
      { option: 'Amenities', id:5},
      { option: 'Gallery', id:6}
    ]
  }
  </code></pre>
  
  <p><strong>containers/form-details</strong></p>
  
  <pre><code>class FormDetail extends Component{
    renderPersonalInfo(){
      return(
        &lt;div className="personalInfo"&gt;
          &lt;div className="col-md-4"&gt;
            &lt;label htmlFor='name'&gt;Owner Name&lt;/label&gt;
            &lt;input ref="name" type="textbox" className="form-control" id="name" placeholder="Owner name" /&gt;
          &lt;/div&gt;
  
          &lt;div className="col-md-4"&gt;
            &lt;label htmlFor="email"&gt;Email&lt;/label&gt;
            &lt;input ref="email" type="email" className="form-control" id="email" placeholder="email" /&gt;
          &lt;/div&gt;
  
          &lt;div className="col-md-4"&gt;
            &lt;label htmlFor="phoneNumber"&gt;Phone Number&lt;/label&gt;
            &lt;input ref="phone" type="textbox" className="form-control" id="phoneNumber" placeholder="phone number" /&gt;
          &lt;/div&gt;
  
          &lt;div className="buttons"&gt;
            &lt;button className="btn btn-primary"&gt;Continue&lt;/button&gt;
          &lt;/div&gt;
  
        &lt;/div&gt;
        );
    }
  
    renderBasicInfo(){
      return(
         &lt;div&gt;
                &lt;h3&gt;Help Rent seekers find the right fit&lt;/h3&gt;
                &lt;p className="subtitle"&gt;People searching on Rental Space can filter by listing basics to find a space that matches their needs.&lt;/p&gt;
                &lt;hr/&gt;
                &lt;div className="col-md-4 basicForm"&gt;
                    &lt;label htmlFor="price"&gt;Property Type&lt;/label&gt;
                    &lt;select className="form-control" name="Property Type" ref="property"&gt;
                        &lt;option value="appartment"&gt;Appartment&lt;/option&gt;
                        &lt;option value="house"&gt;House&lt;/option&gt;
                    &lt;/select&gt;
                &lt;/div&gt;
                &lt;div className="col-md-4 basicForm"&gt;
                    &lt;label htmlFor="price"&gt;Price&lt;/label&gt;
                    &lt;input type="textbox" ref="price" className="form-control" id="price" placeholder="Enter Price" required /&gt;
                &lt;/div&gt;
                &lt;div className="buttons"&gt;
                  &lt;button className="btn btn-primary"&gt;Back&lt;/button&gt;
                  &lt;button className="btn btn-primary"&gt;Continue&lt;/button&gt;
                &lt;/div&gt;
              &lt;/div&gt;
        );
    }
  
    renderDescription(){
      return(
          &lt;div&gt;
              &lt;h3&gt;Tell Rent Seekers about your space&lt;/h3&gt;
              &lt;hr/&gt;
              &lt;div className="col-md-6"&gt;
                  &lt;label htmlFor="listingName"&gt;Listing Name&lt;/label&gt;
                  &lt;input ref="name" type="textbox" className="form-control" id="listingName" placeholder="Be clear" /&gt;
              &lt;/div&gt;
              &lt;div className="col-sm-6"&gt;
                  &lt;label htmlFor="summary"&gt;Summary&lt;/label&gt;
                  &lt;textarea ref="summary" className="form-control" id="summary" rows="3"&gt;&lt;/textarea&gt;
              &lt;/div&gt;
               &lt;div className="buttons"&gt;
                  &lt;button className="btn btn-primary"&gt;Back&lt;/button&gt;
                  &lt;button className="btn btn-primary"&gt;Continue&lt;/button&gt;
               &lt;/div&gt;
          &lt;/div&gt;
        );
    }
  
    renderLocation(){
      return(
          &lt;div&gt;
              &lt;h3&gt;Help guests find your place&lt;/h3&gt;
              &lt;p className="subtitle"&gt;will use this information to find a place that’s in the right spot.&lt;/p&gt;
              &lt;hr/&gt;
              &lt;div className="col-md-6"&gt;
                  &lt;label htmlFor="city"&gt;City&lt;/label&gt;
                  &lt;input ref="city" type="textbox" className="form-control" id="city" placeholder="Biratnagar" /&gt;
              &lt;/div&gt;
              &lt;div className="col-md-6"&gt;
                  &lt;label htmlFor="placeName"&gt;Name of Place&lt;/label&gt;
                  &lt;input ref="place" type="textbox" className="form-control" id="placeName" placeholder="Ganesh Chowk" /&gt;
              &lt;/div&gt;
               &lt;div className="buttons"&gt;
                  &lt;button className="btn btn-primary"&gt;Back&lt;/button&gt;
                  &lt;button className="btn btn-primary"&gt;Continue&lt;/button&gt;
               &lt;/div&gt;
          &lt;/div&gt;
        );
    }
  
    render(){
      if ( !this.props.form){
        return this.renderPersonalInfo();
      }
  
      const type = this.props.form.option;
      console.log('type is', type);
  
      if ( type === 'Personal Information'){
        return this.renderPersonalInfo();
      }
  
      if ( type === 'Basic Information'){
        return this.renderBasicInfo();
      }
  
      if ( type === 'Description'){
        return this.renderDescription();
      }
  
      if ( type === 'Location'){
        return this.renderLocation();
      }
  }
  }
  
  function mapStateToProps(state){
  
    return{
      form: state.activeForm
    };
  }
  
  export default connect(mapStateToProps)(FormDetail);
  </code></pre>