class LangF extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            lan: "English",
            showElem: "none",
        };
    }
    componentWillMount() {
        if (this.props.lan === "kr") {
            this.setState({
                lan: "한국인",
            })
        }
        if (this.props.lan === "vn") {
            this.setState({
                lan: "Việt Nam",
            })
        }
        if (this.props.lan === "ru") {
            this.setState({
                lan: "Русский",
            })
        }
        if (this.props.lan === "id") {
            this.setState({
                lan: "Indonesia",
            })
        }
        if (this.props.lan === "in") {
            this.setState({
                lan: "इंडी",
            })
        }
        if (this.props.lan === "bd") {
            this.setState({
                lan: "বাংলা",
            })
        }
        if (this.props.lan === "my") {
            this.setState({
                lan: "Melayu",
            })
        }

        if (this.props.lan === "ar") {
            this.setState({
                lan: "عرب",
            })
        }
        if (this.props.lan === "hk") {
            this.setState({
                lan: "繁體中文",
            })
        }
        if (this.props.lan === "pt") {
            this.setState({
                lan: "Portugal",
            })
        }
        if (this.props.lan === "tr") {
            this.setState({
                lan: "Türk",
            })
        }
    }
    chooselang(param, event) {
        var str = location.pathname;
        console.log(str);
        if (this.props.lan !== "index") {
            str = str.substring(3)
            console.log(str);
        }
        if (param === 1) {
            location.href = str
        }
        if (param === 2) {
            location.href = "/kr" + str
        }
        if (param === 3) {
            location.href = "/vn" + str
        }
        if (param === 4) {
            location.href = "/ru" + str
        }
        if (param === 5) {
            location.href = "/id" + str
        }
        if (param === 6) {
            location.href = "/in" + str
        }
        if (param === 7) {
            location.href = "/bd" + str
        }
        if (param === 8) {
            location.href = "/my" + str
        }

        if (param === 9) {
            location.href = "/ar" + str
        }
        if (param === 10) {
            location.href = "/hk" + str
        }

        if (param === 11) {
            location.href = "/pt" + str
        }
        if (param === 12) {
            location.href = "/tr" + str
        }
    }
    render() {
        return (
            <div className="lang-select-box"
                onMouseLeave={() => {
                    this.setState({
                        showElem: "none"
                    })
                }}
            >
                <div className="lang-select" onMouseOver={() => {
                    this.setState({
                        showElem: "block"
                    })
                }}>
                    <p className="select_val"
                    >  {this.state.lan}
                    </p>
                    <img src="../static/img/down.svg" alt="" />
                    <div className="select-list select_list" style={{ display: this.state.showElem }}
                        onMouseLeave={() => {
                            this.setState({
                                showElem: "none"
                            })
                        }}
                    >
                        <div className="li" onClick={() => this.chooselang(1)} >English</div>
                        <div className="li" onClick={() => this.chooselang(2)} >한국인</div>
                        <div className="li" onClick={() => this.chooselang(3)} >Việt Nam</div>
                        <div className="li" onClick={() => this.chooselang(4)} >Русский</div>
                        <div className="li" onClick={() => this.chooselang(5)} >Indonesia</div>
                        <div className="li" onClick={() => this.chooselang(6)} >इंडी</div>
                        <div className="li" onClick={() => this.chooselang(7)} >বাংলা</div>
                        <div className="li" onClick={() => this.chooselang(8)} >Melayu</div>
                        <div className="li" onClick={() => this.chooselang(9)} >عرب</div>
                        <div className="li" onClick={() => this.chooselang(10)} >繁體中文</div>
                        <div className="li" onClick={() => this.chooselang(11)} >Portugal</div>
                        <div className="li" onClick={() => this.chooselang(12)} >Türk</div>
                    </div>
                </div>
            </div>
        );
    }
}