{# Template : Messages parent page #}
{% extends 'layouts/members.twig' %}

{% block members_content %}

    {% include 'includes/elements/intro_block.twig' with {
        intro_title: 'Messages',
        intro_content: 'Create and manage messages between you and our doctors or customer service.',
        class: 'membersIntro',
        use_h1: true
    } %}

    <div class="membersContentWrap">


        <div class="messageListWrap">

            <ul class="messageList">

                {% if threads is not empty %}

                {% for thread in threads %}

                    <li class="{% if thread.hasMemberUnread() is not empty %}notRead{% endif %}">

                        <a href="{{ route('messaging.view_thread', thread.url) }}" class="view">


                            {{ thread.getLatestMessageAttribute().text|striptags|truncate(50, true, "...") }}

                            {% if thread.hasMemberUnread() is not empty %}
                                <span class="unreadCount">{{ thread.memberUnreadCount() }}</span>
                            {% endif %}

                            <i class="fal fa-eye"></i>

                        </a>

                    </li>

                {% endfor %}

            </ul>

            <div class="newThreadContainer">
                <a class="button" href="{{ route('messaging.thread') }}">
                    New thread
                </a>
            </div>

            {% else %}

                <p>No message threads found.</p>

                <div class="newThreadContainer">
                    <a class="button" href="{{ route('messaging.thread') }}">
                        New thread
                    </a>
                </div>

            {% endif %}

        </div> <!-- .messageListWrap -->

    </div> <!-- .membersContentGrid -->

{% endblock %}
