{% set legacyBaseLayout = light_display|default(false) ? 'light_display_layout.tpl' : 'layout.tpl' %}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% form_theme form '@Modules/glspoland/views/templates/admin/form_theme.html.twig' %}
{% form_theme form.recipientDetails '@PrestaShop/Admin/TwigTemplateForm/bootstrap_4_layout.html.twig' %}

{% block content %}
  {% set recipientDetailsExpanded = not form.recipientDetails.vars.valid %}

  <div class="row justify-content-center">
    <div class="col">

      <div class="card mb-0">
        {{ form_start(form) }}

        <div class="card-body card-block row">
          <div class="form-wrapper card-text">
            {{ form_errors(form) }}
            {{ form_row(form.type) }}

            <div class="form-group row">
              <label class="form-control-label required">
                {{ form.recipientDetails.vars.label }}
              </label>
              <div class="col-sm">
                <button type="button" class="btn btn-sm btn-outline-secondary" data-toggle="collapse" data-target="#{{ form.recipientDetails.vars.id }}" aria-expanded="{{ recipientDetailsExpanded ? 'true' : 'false' }}">
                  {{ 'show / hide'|trans({}, 'Modules.Glspoland.Admin') }}
                </button>

                <div id="{{ form.recipientDetails.vars.id }}" class="collapse mt-3{{ recipientDetailsExpanded ? ' show' : '' }}">
                  {{ form_errors(form.recipientDetails) }}
                  {{ form_widget(form.recipientDetails) }}
                </div>
              </div>
            </div>

            <div id="{{ form.serviceDetails.vars.id }}">
              {{ form_rest(form.serviceDetails) }}
            </div>

            {{ form_rest(form) }}
          </div>
        </div>

        <div class="card-footer clearfix">
          <button class="btn btn-primary float-right">
            {{ 'Create consignment'|trans({}, 'Modules.Glspoland.Consignment') }}
          </button>
        </div>

        {{ form_end(form) }}
      </div>

      {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with {
        'id': 'parcel_shop_map_modal',
        'class': 'mw-100 w-75',
      } %}
        {% block header %}
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
          </div>
        {% endblock %}

        {% block content %}
          <div id="parcel_shop_map" class="modal-body gls-poland-parcel-shop-map-modal-content"></div>
        {% endblock %}
      {% endembed %}

    </div>
  </div>
{% endblock %}

{% block javascripts %}
  {{ parent() }}

  <script src="{{ asset('js/admin/consignment/form.js', 'GlsPoland') }}"></script>
  <script src="{{ constant('Gls\\GlsPoland\\PrestaShop\\Checkout\\AbstractCheckout::MAP_SDK_JS_URI') }}"></script>
{% endblock %}

{% block stylesheets %}
  {{ parent() }}

  <link rel="stylesheet" href="{{ asset('css/admin/consignment/form.css', 'GlsPoland') }}">
  <link rel="stylesheet" href="{{ constant('Gls\\GlsPoland\\PrestaShop\\Checkout\\AbstractCheckout::MAP_SDK_CSS_URI') }}">
{% endblock %}