{% extends "base.html" %}

{% from "macros.html" import workouts_table with context %}

{% block title %}{{ name }} - Routine{% endblock %}

{% block content_title %}{{ name }}{% endblock %}

{% block content %}
<table class="table is-striped is-centered">
    <thead>
        <tr>
            <th></th>
            <th>Exercise</th>
            <th>Sets</th>
        </tr>
    </thead>
    <tbody>
        {% for i, exercise, set_count in routine %}
        <tr>
            <td class="has-text-centered">E{{ i }}</td>
            <td><a href="{{ url_for('exercise_view', name=exercise) }}">{{ exercise }}</a></td>
            <td class="has-text-centered">{{ set_count }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% if previous_exercises %}
<div class="container has-text-centered mt-6">
    <h1 class="title is-5">Previously used exercises</h1>
    {% for exercise in previous_exercises %}
    <p class="m-2"><a href="{{ url_for('exercise_view', name=exercise) }}">{{ exercise }}</a></p>
    {% endfor %}
</div>
{% endif %}
{% if workouts %}
<div class="container has-text-centered mt-6">
    <h1 class="title is-5">Workouts</h1>
    <div class="container" style="max-width: 360pt">
        {{ diagram|safe }}
    </div>
</div>
<div class="table-container">
    {{ workouts_table(workouts) }}
</div>
{% endif %}
{% endblock %}

{% set parent_page = 'routines_view' %}
