import React, { Component } from "react";
import FaChevronCircleLeft from "react-icons/lib/fa/chevron-circle-left";
import Drawer from "./drawer";
import cookie from 'react-cookies'
import api from './api/api'
class parent extends Component {
  constructor(props) {
    super(props);
    console.log("session", localStorage.getItem("current_state"));
    console.log("is_active", localStorage.getItem("login_is_active"));
    if (
      localStorage.getItem("current_state") !== "parent" )  {
        this.props.history.push("/menu_page");
      }
    this.state = {
      is_active: localStorage.getItem("login_is_active") == 1 ? true : false
    };
  }
  componentDidMount = () => {
    let expectingchild = localStorage.getItem("relation_with_children1");
    this.setState({
      expectingchild: expectingchild
    });
  };
  save_relation(relation) {
    if (relation === "next") {
      localStorage.setItem("current_state", "set_relation");
      this.props.history.push({ pathname: "/set_relation" });
    } else {
      localStorage.setItem("relation_with_children", relation);

      console.log(this.state.expectingchild, relation);
      localStorage.setItem("current_state", "family");
      this.props.history.push({ pathname: "/family" });
    }
  }
  render() {
    return (
    <div>
       {this.state.is_active && <Drawer prop={this.props} />}  
      <div className="bcd_header_div_margin"> 
      <div className="allpages_desktop_boxes_div">
       
        <div>
          <div className="row">
            <table className="index_table" align="center">
              <tbody>
                <tr className="index_tablefirst">
                  <td colSpan="2">
                    <h2 className="iam">I'm...</h2>
                  </td>
                </tr>
                <tr>
                  <td>
                    <button
                      className="btnfuctionality btnfuctionality2"
                      onClick={() => {
                        this.save_relation("father");
                      }}
                    >
                      Father
                    </button>
                  </td>
                  <td>
                    <button
                      className="btnfuctionality btnfuctionality2"
                      onClick={() => {
                        this.save_relation("mother");
                      }}
                    >
                      Mother
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div className="row">
            <div className="col-md-6 col-lg-6 ">
              <img
                src={api.image_path+"prev_arrow_one.jpg"}
                width="40"
                className="next_icon next_left"
                onClick={() => {
                  this.save_relation("next");
                }}
              />
            </div>
          </div>
        </div>
      </div>
     </div> 
     </div>  
    );
  }
}
export default parent;
