class Playbook::PbSource::Source

def avatar

def avatar
  if user.present? && (type == "user" || type == "referral")
    avatar_props = user.clone
    avatar_props[:size] = "sm"
    avatar_props.delete(:user_id)
    avatar_props
  end
end

def classname

def classname
  generate_classname("pb_source_kit")
end

def show_icon?

def show_icon?
  !type_icon_name.nil? && avatar.nil?
end

def type_icon_name

def type_icon_name
  case type
  when "retail"
    "shopping-bag"
  when "inbound"
    "sign-in"
  when "outbound"
    "sign-out"
  when "prospecting"
    "binoculars"
  when "events"
    "calendar-alt"
  when "referral"
    "handshake"
  end
end

def type_text

def type_text
  if type == "user" || (type == "referral" && user.present?)
    user[:name]
  else
    type.titleize
  end
end

def user_id

def user_id
  user.dig(:user_id)
end