{{ attach_library('ui_patterns/tm_itinerary_item.tm_itinerary_item_lib') }}

{% set back_url = back_url|default('/offers-events') %}
{% set back_text = back_text|default('Back to offers') %}
{% set reset_url = reset_url|default('/itinerary-reset') %}
{% set reset_text = reset_text|default('Change details') %}
{% set remove_text = remove_text|default('Remove') %}
{% set clear_url = clear_text|default('/itinerary-clear') %}
{% set clear_text = clear_text|default('Clear itinerary') %}
{% set claim_url = claim_url|default('/itinerary-print') %}
{% set claim_text = claim_text|default('Claim') %}

{% if form_items or claim_items %}
  {% include "@atoms/tm-links/standard/standard.twig" with {
    "url": back_url,
    "text": '<i class="fas fa-chevron-left"></i> ' ~ back_text,
    'class': 'btn-outline-default btn btn-sm',
  } only %}
{% endif %}

{% if form_items %}

  <div id="itin-info">
    <h2>Personal information</h2>

    <div class="itin-claim-wrapper table-responsive-md">
      <table class="itin-claim table">
        <tbody>
        {% for field in form_items %}
          <tr><th>{{ field.title }}</th><td>{{ field.value }}</td></tr>
        {% endfor %}
        </tbody>
      </table>
    </div>

    <p>If this information is not correct, you can go back to the form to change it using the button below</p>

    {% include "@atoms/tm-links/standard/standard.twig" with {
      "url": reset_url,
      "text": '<i class="fas fa-pencil"></i> ' ~ reset_text,
      'class': "btn btn-default btn-sm mb-0"
    } only   %}

    {% include "@atoms/tm-links/standard/standard.twig" with {
      "url": clear_url,
      "text": '<i class="fas fa-trash"></i> ' ~ clear_text,
      'class': "btn btn-outline-default btn-sm mb-0 ms-3"
    } only   %}

    <hr>

  </div>
{% endif %}

{% if claim_items %}

  <h3>Items to print</h3>
  <p>Removing offers and events here will remove them from your ready to print list, not from your itinerary.</p>

  {% for item in claim_items %}
    <div class="itin-review-item itin-item">
      <h4 class="m-0"><i class="fas fa-certificate"></i> {{ item.type }}: <em>{{ item.title }}</em></h4>
      {% if remove_text %}
        {% set remove_attrs = create_attribute()
          .setAttribute('data-itinerary-id', item.iid)
          .setAttribute('data-itinerary-action', 'remove')
        %}
        {% include "@atoms/tm-links/standard/standard.twig" with {
          "text": '<i class="fas fa-trash-alt"></i> ' ~ remove_text,
          'class': 'btn-outline-default btn btn-sm mb-0 ms-auto',
          'attributes': remove_attrs,
        } only %}
      {% endif %}
    </div>
  {% endfor %}

  <h2>All set</h2>
  <p>Now that everything is set, download your itinerary and have a nice day!</p>
  {% include "@atoms/tm-links/standard/standard.twig" with {
    'url': claim_url,
    "text": '<i class="fas fa-print"></i> ' ~ claim_text,
    'class': 'btn-outline-default btn btn-sm mb-0',
  } only %}

{% else %}

  <h2>You have no items in your itinerary</h2>
  <p>Why not add some ?</p>
  {% include "@atoms/tm-links/standard/standard.twig" with {
    "url": back_url,
    "text": '<i class="fas fa-chevron-left"></i> ' ~ back_text,
    'class': 'btn-outline-default btn btn-sm',
  } only %}

{% endif %}
