import React , { useState , useEffect } from 'react';
import { Popover , Dropdown , Input , Spin } from 'antd';
import './branch.scss';
import { getBranch , getTag } from '../GetData/getData';
import SelectOverlay from './SelectOverlay';


export default (({ projectsId , branch , owner , changeBranch , branchList , tagflag = true })=>{
  const [ showValue , setShowValue ] = useState(branch);

  useEffect(()=>{
    setShowValue(branch);
  },[branch])

  const menu = (
    <SelectOverlay 
      changeBranch={changeBranch} 
      tagflag={tagflag} 
      projectsId={projectsId}
      owner={owner}
      branchList={branchList}
      />
  );
  return(
    <Dropdown placement='bottomLeft' overlay={menu} overlayClassName="branch-tagBox-list" trigger={['click']} >
      <div className="branch-tagBox">
        {/* {nav === 0 ?"分支":"标签"} */}
        <span className="color-grey-9 mr3 ml8"><i className="iconfont icon-fenzhi2 font-18"></i></span>
        <span className="ant-dropdown-link task-hide" style={{fontWeight:"500",minWidth:"45px"}}>
          {showValue}
        </span>
        <i className="showtag iconfont icon-sanjiaoxing-down font-15 color-grey-9 mr5 ml5 mt1" />
      </div>
    </Dropdown>
  )
})