# frozen_string_literal: true

module SuccessCriteriaHelper
  def success_criterion_result_icon_classes(sc)
    if sc.passed?
      "bi bi-check text-success"
    elsif sc.failed?
      "bi bi-exclamation-lg text-danger"
    elsif sc.not_applicable?
      "bi bi-dash text-muted"
    else
      "bi bi-question text-warning"
    end
  end

  def success_criterion_edit_button(success_criterion, edit_mode)
    path = if success_criterion.persisted?
             if edit_mode
               success_criterion
             else
               [ :edit,
                success_criterion ]
             end
    else
             success_criterion.element
    end
    link_to tag.i(class: "bi bi-pencil"),
            path,
            class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-secondary'}"
  end
end
