import toUpper from 'lodash/toUpper'
import split from 'lodash/split'
import size from 'lodash/size'

import pipe from 'lodash/fp/pipe'
import take from 'lodash/fp/take'
import join from 'lodash/fp/join'
import map from 'lodash/fp/map'

export const getTeamAbbr = (teamName: string) => {
  const nameParts = split(teamName, ' ')

  return size(nameParts) > 1
    ? pipe(
      map(take(1)),
      join(''),
      toUpper,
    )(nameParts)

    : pipe(
      take(3),
      join(''),
      toUpper,
    )(nameParts[0])
}
