{#
/*
 * Copyright © ProgramCMS. All rights reserved.
 * See COPYING.txt for license details.
 *
 * Developed by Mohamed EL QUCHIRI <elquchiri@gmail.com>
 */
#}
{% set favoritePosts = block.getFavoritePosts() %}
<h3>{{ block.trans('Favorite') }}</h3>
    {% if favoritePosts is empty %}
        <p class="text-muted">{{ block.trans('There are no topics in your favorites.') }}</p>
    {% else %}
        <div class="favorite-list row row-cols-1 row-cols-md-3 g-4 mt-3 mb-5">
            {% for favorite in block.getFavoritePosts() %}
                <div class="col">
                    <div class="card h-100" >
                        <div class="card-body">
                            <a href="{{ block.getPostUrl(favorite) }}">
                                <h6 class="card-title">{{ favorite.getPost().getPostName() }}</h6>
                            </a>
                            <h6 class="card-subtitle mb-2 text-muted">
                                {{ favorite.getPost().getUser().getFullname() }}
                            </h6>
                            <p class="card-text">{{ block.getPreviewText(favorite.getPost().getPostHtml(), 500)|raw }}</p>
                        </div>
                        <div class="card-footer card-actions">
                            <a href="{{ block.getRemoveFavoriteUrl(favorite) }}" class="btn btn-sm btn-danger float-end">{{ block.trans('Delete') }}</a>
                        </div>
                        <div class="card-footer">
                            <small class="text-muted">{{ block.trans('Last updated')}} {{ block.getTimeAgo(favorite.getPost().getUpdatedAt()) }}</small>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% endif %}