import { CLASS_MAP } from '../press-gp-popup-operation/config';

import type { ScheItem } from './types';


export const transformTreeInfoToList = (scheItem: ScheItem) => {
  const {
    sche,
    roundInfo,
    uniqueId,
  } = scheItem || {};
  const {  boType, battleDesc, upTeamInfo, downTeamInfo } = sche;

  const operationClass = {
    未开始: CLASS_MAP.NOT_START,
    上场中: CLASS_MAP.ING,
    比赛中: CLASS_MAP.ING,
    已结束: CLASS_MAP.END,
  };

  const info = {
    uniqueId,
    // title: `【${roundInfo.round_name}】第${curBo}/${boType}局`,
    title: `${roundInfo.round_name} BO${boType}`,
    statusDesc: battleDesc,
    boType,
    class: operationClass[battleDesc as keyof typeof operationClass] || CLASS_MAP.END,
    schId: sche.schId,
    battleId: sche.battleId,
    firstValidBattleId: sche.firstValidBattleId,

    leftTeamName: upTeamInfo.teamNameDesc,
    leftTeamAvatar: upTeamInfo.teamavatar,
    leftTeamScore: upTeamInfo.score,
    leftTeamId: upTeamInfo.teamid,

    rightTeamName: downTeamInfo.teamNameDesc,
    rightTeamAvatar: downTeamInfo.teamavatar,
    rightTeamScore: downTeamInfo.score,
    rightTeamId: downTeamInfo.teamid,
  };

  return info;
};
