import React from 'react'
import PropTypes from 'prop-types'
import _ from 'lodash'

function Icon({type, name}) {  
  let typePrefix
  switch (_.toLower(type)) {
    case 'simplelineicons': case 'icon': case 'sli':
      typePrefix = 'icon-'
      break;
    case 'flag':
      typePrefix = 'flag-icon-'
      break;
    case 'fontawesome': case 'fa':
      typePrefix = 'fa fa-'
      break;
    case 'coreui': case 'cui': default:
      typePrefix = 'cui-'
      break;
  }

  const iconClass = typePrefix + name

  return (
    <i className={iconClass} />
  )
}
export default Icon

Icon.propTypes = {
  type: PropTypes.string.isRequired,
  name: PropTypes.string.isRequired
}
Icon.defaultProps = {
  type: 'coreui',  
}