{% assign talent_lms_learner = current_person.properties.talent_lms_learner %}
{% assign talent_lms_course = course.properties.talent_lms_course %}
{% assign course_previously_completed = false %}
{% if talent_lms_course and talent_lms_learner %}
  {% assign course_previously_completed = true %}
{% endif %}

{% capture course_path %}{% route course, id: course.id %}{% endcapture %}
  {% assign progress_status = "not-started" %}
  {% if course.progress == 0 %}
    {% if course_previously_completed == true %}
      {% assign progress_status = "completed" %}
    {% else %}
      {% assign progress_status = "not-started" %}
    {% endif %}
  {% elsif course.progress == 100 %}
    {% assign progress_status = "completed" %}
  {% else %}
    {% if course_previously_completed == true %}
      {% assign progress_status = "completed" %}
    {% else %}
      {% assign progress_status = "in-progress" %}
    {% endif %}
  {% endif %}

<div class="np-card course-card">
  <a href="{{ course_path }}">
    <div class="np-card-container">
      {% if course.ribbon %}
        <div class="np-card-ribbon list-hide">
          {{ course.ribbon }}
        </div>
      {% endif %}
      {% if course.properties.course_type == "Training" %}
        <div class="np-card-ribbon list-hide course-type-ribbon">
          {{ course.properties.course_type }}
        </div>
      {% endif %}
      <img
        class="np-card-image list-hide"
        alt="{{ course.name }}"
        src="{{ course.image_url }}"
      >
      <div class="np-card-content np-card-content-vertical np-card-padding">
        <img
          class="np-card-image list-show"
          alt="{{ course.name }}"
          src="{{ course.image_url }}"
        >
        <div class="list-card-titles">
          <h3 class="np-card-content-title">
            {{ course.name }}
          </h3>
          <div class="np-card-content-subtitle">
            {{ course.short_description }}
          </div>
        </div>
        <div class="np-card-content-footer">
          <div class="experience">
            {{course.properties.experience}}
          </div>
          <div class="np-card-content-progress {{progress_status}}">
            {% if course.progress == 0 %}
              {% if course_previously_completed == true %}
                Completed on TalentLMS
              {% else %}
                Not started
              {% endif %}          
            {% elsif course.progress == 100 %}
              Completed
            {% else %}
              {% if course_previously_completed == true %}
                Completed on TalentLMS
              {% else %}
                In progress
              {% endif %}
            {% endif %}
          </div>
        </div>
      </div>
    </div>
  </a>

  <div class="course-categories-list" style="display: none;">{{ course.categories | map: "name" }}</div>
</div>
