{% assign is_enrolled_in_new_hire_lp = false %}
{% assign new_hire_progress = 0 %}
{% assign day_offset_in_seconds = 864000 %}
{% assign zoom_url = "NULL" %}
{% assign in_center_group = false %}

{% for learning_path in learning_paths.enrolled %}
  {% for category in learning_path.categories %}
    {% assign category_lowercase = category.name | downcase %}
    {% if category_lowercase == "new hire training" %}
	  <script>
		console.log("User is enrolled to: {{ learning_path.name}})
	  </script>
      {% assign is_enrolled_in_new_hire_lp = true %}
      {% assign new_hire_progress = learning_path.progress %}
      {% break %}
    {% endif %}
  {% endfor %}
{% endfor %}

{% if is_enrolled_in_new_hire_lp == true %}
  {% for course in courses.enrolled %}
    {% if course.properties.instructor_information_course == true %}
      {% assign zoom_url = course.short_description %}
      {% break %}
    {% endif %}
  {% endfor %}
{% endif %}

{% for group in current_person.groups %}
	{% if group.name contains " IC " %}
		{% assign in_center_group = true %}
	{% else %}
		{% assign in_center_group = false %}
	{% endif %}
{% endfor %}


{% include "header" %}
<main class="np-main np-homepage">
  <div class="np-homepage-hero">
    <img
      class="np-homepage-hero-image"
      src="https://s3.amazonaws.com/static.northpass.com/Williams-Sonoma/wsi-hero-min-2.gif"
      alt="{{ homepage.headline }}" />
    <div class="np-homepage-hero-content">
      <div class="np-homepage-headline np-header-font-color">{{ homepage.headline }}</div>
      <div class="np-homepage-subheadline np-header-font-color">
        {{ homepage.subheadline }}
      </div>

    </div>
  </div>
  {% if current_person.email contains "+preview" %}
    {% include "new_hire_homepage"
      , zoom_url: zoom_url %}
  {% else %}
    {% if is_enrolled_in_new_hire_lp == true or in_center_group == true %}
      {% if new_hire_progress == 100 %}
		<script>
		  console.log("User new hire progress is 100")
		</script>
        {% assign today_date = 'now' | date: '%s' | times: 1 %}
        {% assign completed_date = current_person.properties.training_completion_date | date: '%s' | times: 1 %}
        <script>
              window.location.replace("/app/dashboard")
        </script>
        <script>
          console.log("{{ completed_date }}")
        </script>
		{% comment %}
		This will be enabled when the WSGC team is ready. Leave it commented out until then.
		{% if completed_date == 0 %}
                                <script>
                                  window.location.replace("/app/dashboard")
                                </script>
                              {% else %}
                                {% assign completed_date_plus_days = completed_date | plus: day_offset_in_seconds %}
                                {% if today_date > completed_date_plus_days %}
                                  {% include "new_hire_complete_access_denied" %}
                                {% else %}
                                  <script>
                                    window.location.replace("/app/dashboard")
                                  </script>
                                {% endif %}
                      {% endif %} {% endcomment %}
      {% else %}
        {% if new_hire_progress > 0 or in_center_group == true %}
          <script>
            window.location.replace("/app/dashboard")
          </script>
        {% else %}
          {% include "new_hire_homepage"
            , zoom_url: zoom_url %}
        {% endif %}
      {% endif %}
    {% else %}
      {% include "missing_content_notice" %}
    {% endif %}
  {% endif %}
</main>
{% include "footer" %}

<script>
  console.log(`User is enrolled in New Hire Learning Path: {{ is_enrolled_in_new_hire_lp }}`)
  console.log(`Current Progress of New Hire Path: {{ new_hire_progress }}%`)
  console.log(`Zoom URL: {{ zoom_url }}`)
</script>
