/*
 * @Author: 赵伟
 * @Date: 2024-04-18 18:35:41
 * @Description: 编辑器状态组件
 */
import { DevEditorStatus } from '@/enums';
import styles from './index.less';

export type DevEditorStatusInfo = {
  text: string;
  classname: string;
};

export const statusInfo: Record<DevEditorStatus, DevEditorStatusInfo> = {
  [DevEditorStatus.Unknown]: {
    text: '未启动',
    classname: styles['model-deployment-status-cell'],
  },
  [DevEditorStatus.Running]: {
    classname: styles['model-deployment-status-cell--running'],
    text: '运行中',
  },
  [DevEditorStatus.Terminated]: {
    classname: styles['model-deployment-status-cell--terminated'],
    text: '已停止',
  },
  [DevEditorStatus.Failed]: {
    classname: styles['model-deployment-status-cell--error'],
    text: '失败',
  },
  [DevEditorStatus.Pending]: {
    classname: styles['model-deployment-status-cell--pending'],
    text: '启动中',
  },
};

function EditorStatusCell(status?: DevEditorStatus | null) {
  if (status === null || status === undefined || !statusInfo[status]) {
    return <span>--</span>;
  }
  return <span className={statusInfo[status].classname}>{statusInfo[status].text}</span>;
}

export default EditorStatusCell;
