/*
 * @Author: 赵伟
 * @Date: 2024-04-18 18:35:41
 * @Description: 实验状态
 */

import { AutoMLTrailStatus } from '@/enums';
import { ExperimentStatusInfo } from '@/pages/Experiment/status';
import themes from '@/styles/theme.less';
import styles from './index.less';

export const statusInfo: Record<AutoMLTrailStatus, ExperimentStatusInfo> = {
  [AutoMLTrailStatus.SUCCESS]: {
    label: '成功',
    color: themes.successColor,
    icon: '/assets/images/experiment-status/success-icon.png',
  },
  [AutoMLTrailStatus.TIMEOUT]: {
    label: '超时',
    color: themes.pendingColor,
    icon: '/assets/images/experiment-status/pending-icon.png',
  },
  [AutoMLTrailStatus.FAILURE]: {
    label: '失败',
    color: themes.errorColor,
    icon: '/assets/images/experiment-status/fail-icon.png',
  },
  [AutoMLTrailStatus.CRASHED]: {
    label: '崩溃',
    color: themes.errorColor,
    icon: '/assets/images/experiment-status/fail-icon.png',
  },
  [AutoMLTrailStatus.CANCELLED]: {
    label: '取消',
    color: themes.abortColor,
    icon: '/assets/images/experiment-status/omitted-icon.png',
  },
  [AutoMLTrailStatus.STOP]: {
    label: '停止',
    color: themes.textColor,
    icon: '/assets/images/experiment-status/omitted-icon.png',
  },
  [AutoMLTrailStatus.MEMOUT]: {
    label: '内存溢出',
    color: themes.errorColor,
    icon: '/assets/images/experiment-status/fail-icon.png',
  },
};

function TrialStatusCell(status?: AutoMLTrailStatus | null) {
  if (status === null || status === undefined) {
    return <span>--</span>;
  }
  return (
    <div className={styles['trial-status-cell']}>
      {/* <img
        style={{ width: '17px', marginRight: '7px' }}
        src={statusInfo[status]?.icon}
        draggable={false}
        alt=""
      /> */}
      <span
        style={{ color: statusInfo[status] ? statusInfo[status].color : themes.textColor }}
        className={styles['trial-status-cell__label']}
      >
        {statusInfo[status] ? statusInfo[status].label : '未知'}
      </span>
    </div>
  );
}

export default TrialStatusCell;
