import constant, { icons } from './constant'

export const getLeveByScoreId = (score?: string | number) => {
  if (!score && typeof score !== 'number') {
    return {}
  }
  let leve: any = 1
  if (score > 20 && score <= 40) {
    leve = 2
  } else if (score > 40 && score <= 60) {
    leve = 3
  } else if (score > 60 && score <= 80) {
    leve = 4
  } else if (score > 80) {
    leve = 5
  }
  return leve
}

export const getLeveByScore = (score?: string | number) => {
  if (!score && typeof score !== 'number') {
    return {}
  }
  let leve: any = getLeveByScoreId(score)
  return (constant as any)[leve]
}

export const getLeveByScoreMeasure = (score?: string | number) => {
  if (!score && typeof score !== 'number') {
    return {}
  }
  let leve: any = 1
  if (score >= 40 && score < 70) {
    leve = 2
  } else if (score >= 70 && score < 90) {
    leve = 3
  } else if (score >= 90) {
    leve = 4
  }
  return (icons as any)[leve]
}
