{# 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="/members/messages/view_thread.php?thread={{ thread.url }}" class="view">


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

                            {% 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="/members/messages/new.php" title="New Message">
                    New thread
                </a>
            </div>

            {% else %}

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

                <div class="newThreadContainer">
                    <a class="button" href="/members/messages/new.php" title="New Message">
                        New thread
                    </a>
                </div>

            {% endif %}

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

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

{% endblock %}
