{% import "helper.twig" as helper %}

<div class="row mt-2">
    <div class="col-md-8">
        <div class="row">
            <div class="col-md-3 col-lg-4 col-4 mt-auto mb-auto">
                {% if project.masterPictureAttachment %}
                    <a href="{{ entity_url(project.masterPictureAttachment, 'file_view') }}" data-turbo="false" target="_blank" rel="noopener">
                        <img class="d-block w-100 img-fluid img-thumbnail bg-body-tertiary part-info-image" src="{{ entity_url(project.masterPictureAttachment, 'file_view') }}" alt="">
                    </a>
                {% else %}
                    <img src="{{ asset('img/part_placeholder.svg') }}" class="img-fluid img-thumbnail bg-body-tertiary mb-2 " alt="Part main image" height="300" width="300">
                {% endif %}
            </div>
            <div class="col-md-9 col-lg-8 col-7">
                <h3 class="w-fit" title="{% trans %}name.label{% endtrans %}">{{ project.name }}
                    {# You need edit permission to use the edit button #}
                    {% if is_granted('edit', project) %}
                        <a href="{{ entity_url(project, 'edit') }}"><i class="fas fa-fw fa-sm fa-edit"></i></a>
                    {% endif %}
                </h3>
                <h6 class="text-muted w-fit" title="{% trans %}description.label{% endtrans %}"><span>{{ project.description|format_markdown(true) }}</span></h6>
                {% if project.buildPart %}
                    <h6>{% trans %}project.edit.associated_build_part{% endtrans %}:</h6>
                    <a href="{{ entity_url(project.buildPart) }}">{{ project.buildPart.name }}</a>
                {% endif %}

            </div>
        </div>
    </div>


    <div class="col-md-4"> {# Sidebar panel with infos about last creation date, etc. #}
        <div class="mb-3">
            <span class="text-muted" title="{% trans %}lastModified{% endtrans %}">
                <i class="fas fa-history fa-fw"></i>  {{ helper.date_user_combination(project, true) }}
            </span>
            <br>
            <span class="text-muted mt-1" title="{% trans %}createdAt{% endtrans %}">
                <i class="fas fa-calendar-plus fa-fw"></i> {{ helper.date_user_combination(project, false) }}
            </span>
        </div>

        <div class="mt-1">
            <h6>
                {{ helper.project_status_to_badge(project.status) }}
            </h6>
        </div>
        <div class="mt-1">
            <h6>
                <span class="badge badge-primary bg-primary">
                    <i class="fa-solid fa-list-check fa-fw"></i>
                    {{ project.bomEntries | length }}
                    {% trans %}project.info.bom_entries_count{% endtrans %}
                </span>
            </h6>
        </div>
        {% if project.children is not empty %}
            <div class="mt-1">
                <h6>
                <span class="badge badge-primary bg-secondary">
                    <i class="fa-solid fa-folder-tree fa-fw"></i>
                    {{ project.children | length }}
                    {% trans %}project.info.sub_projects_count{% endtrans %}
                </span>
                </h6>
            </div>
        {% endif %}
    </div>

    {% if project.comment is not empty %}
        <p>
        <h5>{% trans %}comment.label{% endtrans %}:</h5>
        {{ project.comment|format_markdown }}
        </p>
    {% endif %}
</div>