import { Tooltip, Tag } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import React, { useEffect,useState } from 'react';
import { connect, SelectLang } from 'umi';
import Avatar from './AvatarDropdown';
import HeaderSearch from '../HeaderSearch';
import styles from './index.less';
import NoticeIconView from './NoticeIconView';
const ENVTagColor = {
  dev: 'orange',
  test: 'green',
  pre: '#87d068',
};

const GlobalHeaderRight = (props) => {
  console.log('right')
  const { theme, layout,dispatch ,taskName} = props;
  const [ idInfo,setIdInfo ] = useState({})
  let className = styles.right;

  if (theme === 'dark' && layout === 'top') {
    className = `${styles.right}  ${styles.dark}`;
  }

  // useEffect(()=>{
  //   let token = window.location.search.split('token=') && window.location.search.split('token=')[1];
  //   dispatch({
  //     type: 'editReport/getIdByToken',
  //     payload: {
  //       token
  //     }
  //   }).then(res=>{
  //     //{result: "fail", cause: "身份验证失败，请重新点击按钮进入答题页面"}
  //     if(res.result === 'success'){
  //       let idInfo = {
  //         roleId:res.roleId,
  //         caseId:res.caseId,
  //         examId:res.examId,
  //         userId:res.userId,
  //         case_take_id:res.caseId + '-' + res.examId,
  //       }
  //       setIdInfo(idInfo);
  //     }else{
  //       //错误处理
  //       console.log(res)
  //     }
  //   })
  // },[])


  useEffect(()=>{
    dispatch({
      type: 'report/getTaskName',
      payload: { examId: idInfo.examId }
    });
  },[dispatch,idInfo.examId])
  return (
    <div className={className}>
      {/*<NoticeIconView />*/}
      <h3>{taskName || ''}</h3>
      {/*<SelectLang className={styles.action}/>*/}
    </div>
  );
};

export default connect(({ report,settings }) => ({
  theme: settings.navTheme,
  layout: settings.layout,
  taskName:report.taskName,
}))(GlobalHeaderRight);
