{#**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 *#}

<div class="row">
  <div class="col">
    <ul class="list-unstyled ml-5">
      {% for message in customerThreadView.messages %}
        {% if not loop.first %}
          <li>
            <hr class="mb-3 mt-0">
          </li>
        {% endif %}

        <li class="media">
          {% if message.type == 'customer' %}
            <i class="material-icons thread-message-icon">person</i>
          {% else %}
            <img class="rounded-circle thread-message-employee-image" src="{{ message.employeeImage }}">
          {% endif %}

          <div class="media-body ml-2">
            <h4 class="mt-0 mb-1">
              <i class="material-icons text-muted">reply</i>

              {% if message.type == constant('PrestaShop\\PrestaShop\\Core\\Domain\\CustomerService\\ValueObject\\CustomerThreadMessageType::CUSTOMER') %}
                {{ message.customerName }}
              {% else %}
                {{ message.employeeName }}
              {% endif %}

              <span class="text-muted">
                <i class="material-icons text-muted font-16">calendar_today</i>
                -
                {{ format_date(message.date) }}
                <i class="material-icons text-muted font-16">access_time</i>
                -
                {{ message.date|date('H:i') }}
              </span>

              {% if message.attachmentFile %}
                <i class="material-icons font-16">attachment</i>
                <a href="{{ message.attachmentFile }}" target="_blank">
                  {{ 'Attachment'|trans({}, 'Admin.Catalog.Feature') }}
                </a>
              {% endif %}

              {% if message.productId %}
                <i class="material-icons font-16">library_books</i>
                <a href="{{ path('admin_product_form', {'id': message.productId}) }}">
                  {{ 'Product'|trans({}, 'Admin.Global') }}
                  {{ message.productName }}
                </a>
              {% endif %}
            </h4>
            <p class="pl-2 thread-message">{{ message.message|nl2br }}</p>
          </div>
        </li>
      {% endfor %}
    </ul>
  </div>
</div>
