{% extends 'base.html.twig' %}

{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{{ path('app_project') }}">{{ 'breadcrumb.projects'|trans }}</a></li>
{% endblock %}

{% block page_title %}{{ 'title.projects'|trans }}{% endblock %}

{% block page_content %}
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<div class="row">
    <div class="col mb-3">
        <div class="btn-group">
            <a href="{{ path('app_project_create') }}" class="btn btn-secondary" accesskey="C">{{ 'button.create_project'|trans }}</a>
        </div>
    </div>
</div>
{% endif %}

{% if projects is not empty %}
<div class="row">
    {% for project in projects %}
    <div class="col-12 col-md-4 mb-3">
        <div class="card h-100">
            <div class="card-body">
                <h2 class="card-title">
                    {{ project.name }}
                    {% for tag in project.tags %}
                    <span class="badge text-bg-info ms-2">{{ tag.name }}</span>
                    {% endfor %}
                </h2>
                <p class="card-subtitle mb-2 text-muted">{% include 'partials/_project-metadata.html.twig' %}</p>
                {% if project.description %}<p class="card-text">{{ project.description|markdown_to_html }}</p>{% endif %}
                <a href="{{ path('app_project_show', {'slug': project.slug}) }}" class="btn btn-primary">{{ 'button.details'|trans }}</a>
            </div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
{% if not is_granted('IS_AUTHENTICATED_FULLY') %}
<p>{{ 'text.login_to_create_project'|trans }}</p>
{% endif %}
{% endif %}
{% endblock %}
