{{ header }}
<section
  class="container-fluid"
  id="address-message-info"
  data-success="{{ success }}"
  data-warning="{{ error_warning }}"
>
  {% if content_top %}
    {{ content_top }}
  {% endif %}
  {{breadcrumbs}}
  <div class="row">
    <div class="col-xs-12 col-md-3 hidden-md-down">
      <div class="content-box js-fixed-on-top">
        {{ account }}
      </div>
    </div>
    <div class="col-xs">
      <div class="content-box">
        <div class="flex middle-xs">
          <a href="{{ back }}" class="padding-small text-x-large text-dark hidden-md-up">
            <i class="fas fa-angle-left" aria-hidden="true"></i>
          </a>
          <span class="heading-1">{{ heading_title }}</span>
        </div>
        <div class="paper padding-large vertical-margin-medium flex flex-row center-xs">
          <a href="{{ insert }}" class="btn-default btn-medium">
            <span>{{ button_new_address }}</span>
          </a>
        </div>
        {% for result in addresses %}
          <div class="paper bottom-padding-large left-padding-large bottom-margin-medium">
            <div class="row no-space-xs">
              {% if result.default %}
                <div class="col-xs-12">
                  <div class="content-box top-padding-large right-padding-large">
                    <span class="visible-block text-medium text-dark text-bold">{{ text_default }}</span>
                  </div>
                </div>
              {% endif %}
              <div class="col-xs-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">{{ text_name }}</span>
                  <span class="visible-block text-medium text-dark text-bold">{{ result.firstname }} {{ result.lastname }}</span>
                </div>
              </div>
              <div class="col-xs-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">{{ text_local }}</span>
                  <span class="visible-block text-medium text-dark text-bold">{{ result.apelido ? result.apelido : '-' }}</span>
                </div>
              </div>
              <div class="col-xs-12 col-md-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">Endereço</span>
                  <span class="visible-block text-medium text-dark text-bold">
                    {{ result.address_1 }}, {{ result.numero }}
                    {{ result.address_2 ? '<br>' ~ result.address_2 : '' }}
                  </span>
                </div>
              </div>
              <div class="col-xs-12 col-md-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">{{ text_complement }}</span>
                  <span class="visible-block text-medium text-dark text-bold">{{ result.complemento ? result.complemento : '-' }}</span>
                </div>
              </div>
              <div class="col-xs-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">{{ text_city }}</span>
                  <span class="visible-block text-medium text-dark text-bold">{{ result.city }} - {{ result.zone_code }}</span>
                </div>
              </div>
              <div class="col-xs-6">
                <div class="content-box top-padding-large right-padding-large">
                  <span class="visible-block text-small text-gray bottom-margin-x-small">{{ text_postcode }}</span>
                  <span class="visible-block text-medium text-dark text-bold">{{ result.postcode ? result.postcode[:5] ~ '-' ~ result.postcode[5:] : '' }}</span>
                </div>
              </div>
              <div class="col-xs-12">
                <div class="content-box top-padding-medium right-padding-large flex">
                  <a href="{{ result.update }}" class="btn-default btn-medium right-margin-small top-margin-small">
                    <span>Editar endereço</span>
                  </a>
                  <a href="{{ result.delete }}" class="btn-default btn-medium btn-outline top-margin-small">
                    <span>Deletar endereço</span>
                  </a>
                </div>
              </div>
            </div>
          </div>
        {% endfor %}

      </div>
    </div>
    {% if column_right %}
      <div class="col-md-3 hidden-md-down">
        {{ column_right }}
      </div>
    {% endif %}
  </div>
  {% if content_bottom %}
    {{ content_bottom }}
  {% endif %}
</section>
{{ footer }}

<script type="text/javascript">
  window.waitEvent('scripts_document', function () {
    var success = $('#address-message-info').data('success');
    var warning = $('#address-message-info').data('warning');
    if (success.length > 0) {
      notificationMsg(success, 'success');
    }
    if (warning.length > 0) {
      notificationMsg(warning, 'warning');
    }
  });
</script>
