{#
/**
 * @author
 * Altcom Ltd — 2023
 * @file
 * ScotRail theme implementation to display the results of a FlexipassCheckService call between two stations.
 *
 * Available variables:
 * - result: Whether the FlexipassCheckService call returned true: 'success'; false: 'failure'; or no result: 'message'.
 * - message: Message to return to customer to tell them whether the route has Flexipass.
 *
 * @ingroup themeable
 */
#}

<div class="row message-container {{ result }}">
  <div class="col-sm-12 col-md-8">
  {%if result == 'success' -%}
    {# If the result of the FlexipassCheckService call is 'success' then there are Flexipass tickets available. #}
    {% embed '@molecules/tm-message/alert/alert.twig' with {
      'status': 'success',
      'header': message,
    } only %}
    {% endembed %}
  {% elseif result == 'failure' %}
    {# If the result of the FlexipassCheckService call is 'failure' then Flexipass tickets are not available on this route. #}
    {% embed '@molecules/tm-message/alert/alert.twig' with {
      'status': 'info',
      'header': message,
    } only %}
    {% endembed %}
  {% else %}
    {# Display the default message before a look up is made or if the check can't be made. #}
    {% embed '@molecules/tm-message/alert/alert.twig' with {
      'status': 'info',
      'content': message,
    } only %}
    {% endembed %}
  {% endif %}
  </div>
  {% set spinner %}
    {% include "@molecules/tm-bs/spinner/spinner.twig" with {
      'ajax': true
    } only %}
  {% endset %}
  <div class="col-sm-12 col-md-4 text-md-end">
    {{ altcom_ajax_button(
      element.label ~ ' ' ~ spinner,
      element.callback,
      element.ajax_id,
      {
        'form_id': element.form_id,
        'block_id': element.block_id,
        'cache_tag': element.cache_tag,
        'label': element.label,
        'callback': element.callback,
        'ajax_id': element.ajax_id
      })
    }}
  </div>
</div>
