/*
  releaseClass: dict.type[DICT_TYPE.TOY_RELEASE_GRADE]
 */
import options from '@/utils/dict/options'

const classFormatter = (releaseClassAge = '') => {
  const releaseClass = options.toyReleaseClass
  if (!releaseClassAge) return '--'
  const releaseClassList = Object.values(releaseClass)
  const filterRes = releaseClassList.filter(item => releaseClassAge.split(',').includes(item.value))
  return filterRes && filterRes.length > 0 ? filterRes.map(i => i.label).join(',') : '--'
}
const toyBrandFormatter = (brandId, list) => {
  if (!brandId || !list || list.length === 0) return '--'
  return list.filter(item => item.id === brandId).map(brand => brand.brandName).join(',') || '--'
}

const participantFormatter = (list = []) => {
  let platform, kindergarten, professor
  if (list.length > 0) {
    platform = list.filter(user => user.participantType === options.participantTypeMap.platform.value).map(item => item.userName).filter(k => k).join(',')
    kindergarten = list.filter(user => user.participantType === options.participantTypeMap.kindergarten.value).map(item => item.userName).filter(k => k).join(',')
    professor = list.filter(user => user.participantType === options.participantTypeMap.professor.value).map(item => item.userName).filter(k => k).join(',')
  }
  return {
    platform: platform ? { label: '平台', nameStr: platform } : null,
    kindergarten: kindergarten ? { label: '幼儿园', nameStr: kindergarten } : null,
    professor: professor ? { label: '专家', nameStr: professor } : null
  }
}
export {
  classFormatter,
  toyBrandFormatter,
  participantFormatter
}
