{% include "header" %}
{% include "course_version_outdated_alert", courses: courses.enrolled %}
{% comment %} {% include "sub_navigation" %} {% endcomment %}
{% assign groups = current_person.groups | map: 'name'%}
{% assign completed_nz_count = 0 %}
{% assign nz_status = false%}

{% if groups contains 'NZ Mandatory Training' %}
  {% for course in courses.enrolled %}
    {% if course.properties.nz_aus_courses %}
      {% if course.completed? %}
        {% assign completed_nz_count = completed_nz_count | plus: 1 %}
      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}

<main class="np-main np-courses np-subpage-container np-max-width">
  <div class="np-resource-title" style="font-size: 2.5rem">
    {% comment %} {% t shared.course_vocabulary.plural, key: current_school.course_vocabulary %} {% endcomment %}
    <div {% if groups contains 'NZ Mandatory Training' %}class="courses_page_title"{% endif %}>Resource Center</div>
  </div>
  <div class="np-resource-subtitle">
    {% comment %} {% t .headline, key: current_school.course_vocabulary %} {% endcomment %}
    Hey {{current_person.first_name}}, welcome to the Dasher Resource Center.  You can review best practices used by experienced Dashers.
    {% if groups contains 'NZ Mandatory Training' %}
      {% include 'group_selection' %}
    {% endif %}
  </div>

  {% if groups contains 'NZ Mandatory Training' %}
    {% assign nz_status = true %}
    {% if completed_nz_count > 0%}
      <div class="np-resource-title">
        <div class="courses_page_title">
          Completed Courses
        </div>
      </div>
      <div class="row row-with-thumbnails">
        {% for course in courses.enrolled %}
          {% if course.properties.nz_aus_courses %}
            {% if course.completed? %}
              {% include 'cards_course' with course, nz_status%}
            {% endif %}
          {% endif %}
        {% endfor %}
      </div>

    {% endif %}
  {% endif %}

  <div class="np-resource-title">
    <div {% if groups contains 'NZ Mandatory Training' %}class="courses_page_title"{% endif %}>Enrolled Courses</div>
  </div>
  {% include "courses_index", class: "col-xs-12 col-sm-6 col-lg-4 np-stretch-content" %}
</main>
{% include "footer" %}

{% if groups contains 'NZ Mandatory Training' %}
  <script>
    $('div[course-vehicle]').hide()
    $(document).ready(function() {
      console.log('{{ current_person.properties.learner_vehicle }}')
      if ($('.group-selection-select')[0].value == 'Car') {
        $('[course-vehicle]').each(function() {
          console.log($(this).attr('course-vehicle')[0])
          if ($(this).attr('course-vehicle')[0] == '1') {
            $(this).show()
            console.log(123)
          }
        })
      }
      else if ($('.group-selection-select')[0].value == 'Bike') {
        $('[course-vehicle]').each(function() {
          if ($(this).attr('course-vehicle')[1] == '1') {
            $(this).show()
            console.log(321)
          }
        })
      }
      else if ($('.group-selection-select')[0].value == 'Scooter/Motorbike') {
        $('[course-vehicle]').each(function() {
          if ($(this).attr('course-vehicle')[2] == '1') {
            $(this).show()
            console.log(321)
          }
        })
      }
    });
  </script>
{% endif %}
