{#
/**
 * @file
 * Default theme implementation to display a Apigee Rate Plan entity rendered
 * in Full view mode.
 *
 * This template uses Apigee Edge's default entity template, which can be found
 * at apigee_edge/templates/apigee-entity.html.twig.
 *
 * Additional variables:
 *
 * @ingroup themeable
 */
#}

{% extends 'apigee-entity.html.twig' %}
{% block content %}

  {{ attach_library('apigee_kickstart/monetization') }}

  <div class="container py-5">

    <div class="row">
      <div class="col-lg-6">
        <div class="bg-lighter p-4 rounded-lg">
          {{ content|without(
            'setupFees',
            'recurringFees',
            'consumptionFee',
            'consumptionPricingRates',
            'consumptionPricingType',
            'revenueShareType',
            'revenueShareRates',
            'feeFrequency',
            'purchase'
            ) }}
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col-lg-6">

      {% if content.setupFees|render|striptags|trim is not empty or content.recurringFees|render|striptags|trim is not empty %}
        <div class="rate-plan__card rate-plan__card--fees bg-lighter p-4 my-5 rounded-lg">
          <h2>{{ 'Fees'|t }}</h2>
          {{ content.setupFees }}
          {{ content.recurringFees }}
          {% if content.recurringFees|render|striptags|trim is not empty %}
            {{ content.feeFrequency }}
          {% endif %}
        </div>
      {% endif %}

        {% if content.consumptionPricingRates|render|striptags|trim is not empty %}
          <div class="rate-plan__card rate-plan__card--fees bg-lighter p-4 my-5 rounded-lg">
            <h2>{{ 'Consumption Fees'|t }}</h2>
            {{ content.consumptionPricingType }}

            {% if content.consumptionPricingRates[0]['#singleConsumptionText'] %}
              {{ content.consumptionPricingRates }}
            {% else %}
              <div class="rate-plan-detail__table px-4 py-2 mt-4 bg-white">
                <table class="table table-borderless mb-0">
                  <thead>
                    <tr>
                      <th scope="col">{{ 'Volume Bands'|t }}</th>
                      <th scope="col">{{ 'Cost per API call'|t }}</th>
                    </tr>
                  </thead>
                  <tbody>
                    {{ content.consumptionPricingRates }}
                  </tbody>
                </table>
              </div>
            {% endif %}
          </div>
        {% endif %}

        {% if content.revenueShareRates|render|striptags|trim is not empty %}
          <div class="rate-plan__card rate-plan__card--fees bg-lighter p-4 my-5 rounded-lg">
            <h2>{{ 'Revenue Sharing'|t }}</h2>
            {{ content.revenueShareType }}

          {% if content.revenueShareRates[0]['#singleShareText'] %}
              {{ content.revenueShareRates }}
            {% else %}
              <div class="rate-plan-detail__table px-4 py-2 mt-4 bg-white">
                <table class="table table-borderless mb-0">
                  <thead>
                    <tr>
                      <th scope="col">{{ 'Volume Bands'|t }}</th>
                      <th scope="col">{{ 'Developer Share Percentage'|t }}</th>
                    </tr>
                  </thead>
                  <tbody>
                    {{ content.revenueShareRates }}
                  </tbody>
                </table>
              </div>
            {% endif %}
          </div>
        {% endif %}

        {% if content.purchase %}
          <div class="rate-plan__card rate-plan__card--purchase bg-lighter p-4 mt-4 rounded-lg" id="purchase">
            <h2>{{ 'Purchase'|t }} {{ label }}</h2>
            {{ content.purchase }}
          </div>
        {% endif %}
      </div>
    </div>

  </div>

{% endblock %}
