import React from "react";
import CircularProgress from "@material-ui/core/CircularProgress";
import Drawer from "./drawer";
import Dialog from "material-ui/Dialog";
import FlatButton from "material-ui/FlatButton";
import cookie from 'react-cookies';
import api from './api/api'
class won2 extends React.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") !== "won2" )  {
        this.props.history.push("/menu_page");
      }
    let user_id = cookie.load("user_id");
    console.log("user_id", user_id);
    this.state = {
      isOpen: false,
      loader: false,
      user_id: user_id,
      open: false,
      alertmsg: "",

      contest: {},
      show_error: false,
      error: "",
      is_active: localStorage.getItem("login_is_active") == 1 ? true : false
    };
  }

  handleCancel = () => {
    this.setState({ isOpen: false });
  };

  render() {
    // const image_url = "./images/image-2-contest-budget-app.jpg";
    return (
      <div className="won_first_div">
        <center className="userbirthdatecenter_tag">
          {this.state.is_active && <Drawer prop={this.props} />}
          {this.state.loader && (
            <center>
              <CircularProgress
                size={100}
                style={{ color: "black", marginTop: "17%" }}
              />
            </center>
          )}
          <Dialog
            style={{ textTransform: "capitalize" }}
            actions={
              <FlatButton
                label="OK"
                labelStyle={{ color: "#000" }}
                onClick={() => this.handleClose()}
              />
            }
            modal={false}
            open={this.state.open}
          >
            {this.state.alertmsg}
          </Dialog>
          <div className="won_white_container">
            <div className="won_transparent_div">
              <div className="won_imgtext_div">
                <p>Congratulations !</p>
                <p>You've</p>
                <img src={api.image_path+"won.png"} className="won_imgtext" />
              </div>
            </div>
            <div className="won2_inputtext_div">
              <p>An email with shipping information will be sent to you</p>
              <b>within 30 days</b>
              <br />
            </div>
            <div className="won2_menu_div">
              <a
                onClick={() => {
                  localStorage.setItem("current_state", "menu_page")
                  this.props.history.push("/menu_page");
                }}
                className="won_anchortag"
              >
                <img src={api.image_path+"prev_arrow.jpg"} alt="" title="" width="20" />
                Menu
              </a>
            </div>
          </div>
        </center>
      </div>
    );
  }
}

export default won2;
