import  React from "react"
import {WeaLocaleProvider, WeaProgress} from "ecCom";

const getLabel = WeaLocaleProvider.getLabel;

class SycnProcess extends React.Component{

    constructor(props) {
        super(props);
    }

    render() {

        const {type, syncData} = this.props;
        if(!syncData){
            return ;
        }
        let tempSyncData  = Number(syncData);
        let typeName = type === 1 ? getLabel('506795','分部同步')  : type === 2 ? getLabel('506796','部门同步')  : getLabel('386890','人员同步');
        let stateName ="";
        if(tempSyncData){
            if(tempSyncData==100){
                stateName = getLabel('506797', '同步结束');
            }else if(tempSyncData==0){
                stateName = getLabel('506798', '未同步');
            }else if(tempSyncData==-1){
                stateName = getLabel('508158','coremail未启用');
            }else if(tempSyncData==-2){
                stateName = getLabel('508159','coremail同步组织架构开关没开启');
            }else if(tempSyncData==-3){
                stateName = getLabel('508160','同步中出现异常');
            }else if(tempSyncData>0&&tempSyncData<100){
                stateName = getLabel('391133', '同步中');
            }else{
                stateName = getLabel('32104','异常');
            }
        }
        
        return <div>
            <div>{typeName}:{stateName}</div>
            { syncData  === -1|| tempSyncData< 0 ? <div style={{height: '20px'}}></div> :
                <WeaProgress ecId={`${this && this.props && this.props.ecId || ''}_WeaProgress@y2tqku`} className={"int-initial-process"} percent={tempSyncData ?tempSyncData:0}
                             strokeColor="#81C7FC"/>}
        </div>
    }

}

export default SycnProcess;