import { Component } from "react";
import { connect } from "dva";
import router from "umi/router";

@connect(({ global }) => ({
  global,
}))
export default class BasicIframe extends Component {
  constructor(props) {
    super(props);
    this.userInfo = JSON.parse(localStorage.user_info);
    this.userName = this.userInfo.user_name;
    (this.url_9710 = this.userInfo.url_9710),
      (this.state = {
        userName: this.userName,
        url9710: this.url_9710,
        src: `${this.url9710}&username=${this.userName}`,
        currentSite: props.global.currentSite,
      });
  }

  componentDidMount() {
    const { currentSite } = this.state;
    if (currentSite !== "1") {
      router.push("/order/enquiry");
    }
  }

  render() {
    const { url9710 } = this.state;
    return (
      <div style={{ width: "100%", height: "100%" }}>
        <iframe
          src={url9710}
          title="Example Page"
          width="100%"
          height="100%"
          frameBorder="0"
          allowFullScreen
        />
      </div>
    );
  }
}
