import Ember from 'ember'

Component =  Ember.Component.extend
  tagName: 'span'
  classNames: ['ui', 'label', 'state-badge']
  classNameBindings: ['ui_class', 'having_action:with-action', 'basic:basic']
  action: null
  state: '&hellip;'
  human_state: Ember.computed 'state', ->
    return '-' unless state = @get('state')
    t("attributes.state.#{state}", default: state)
  having_action: Ember.computed.bool 'action'
  click: ->
    @action?()
  ui_class: Ember.computed 'state', ->
    switch @get('state')
      when 'overdue'                    then 'yellow'
      when 'completed', 'all_completed' then 'green'
      when 'rejected',  'any_rejected'  then 'red'
      when 'active',    'processing'    then 'blue'
      when 'inquiry'                    then 'pink'
      else                                   'grey'

Component.reopenClass
  positionalParams: ['state']

export default Component
