﻿class EnterpriseDataWaterMark extends React.Component {
    constructor(props) {
        super(props);
        this.state = { id: this.props.idEnt, enterpriseName: '', enterpriseLogo: [] }

    }
    render() {
        const encode64 = (data) => {
            var output = "";
            var str = "";
            for (var i = 0; i < data.length; i++) {
                str += String.fromCharCode(data[i]);

                if (str.length == 57 && i != data.length - 1) {
                    output += btoa(str) + "\n";
                    str = "";
                }
            }
            return output + btoa(str);
        }

        return (
            <div>
                <div className="waterMark-logo">
                    <img src={((this.state.enterpriseLogo != null) ? "data:image/png;base64," + encode64(this.state.enterpriseLogo) : '/images/products/noImage.png')} />
                </div>


            </div>
        )
    }
    componentDidMount = async () => {
        // if (this.id > -1) {
        const entLo = await fetch("/global/GetEnterpriseData?entId=" + this.state.id, { method: 'post' });
        const entLog = await entLo.json();
        this.setState({ enterpriseName: entLog.commercialName, enterpriseLogo: entLog.enterpriseLogo })
        //}
    }
}