/*
 * @Author: 赵伟
 * @Date: 2024-04-18 18:35:41
 * @Description: 模型部署状态
 */
import { ModelDeploymentStatus } from '@/enums';
import styles from './index.less';

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

export const statusInfo: Record<ModelDeploymentStatus, ModelDeploymentStatusInfo> = {
  [ModelDeploymentStatus.Init]: {
    text: '启动中',
    classname: styles['model-deployment-status-cell'],
  },
  [ModelDeploymentStatus.Running]: {
    classname: styles['model-deployment-status-cell--running'],
    text: '运行中',
  },
  [ModelDeploymentStatus.Stopped]: {
    classname: styles['model-deployment-status-cell--stopped'],
    text: '已停止',
  },
  [ModelDeploymentStatus.Failed]: {
    classname: styles['model-deployment-status-cell--error'],
    text: '失败',
  },
  [ModelDeploymentStatus.Pending]: {
    classname: styles['model-deployment-status-cell--pending'],
    text: '挂起中',
  },
};

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

export default ModelDeploymentStatusCell;
