{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h2">Portafogli</h1>
    <a href="{% url 'portfolio_create' %}" class="btn btn-primary">Aggiungi Portafoglio</a>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th scope="col">Nome</th>
                        <th scope="col">Cliente</th>
                        <th scope="col">Data Creazione</th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for portfolio in portfolios %}
                    <tr>
                        <td>{{ portfolio.name }}</td>
                        <td>{{ portfolio.client.name }}</td>
                        <td>{{ portfolio.created_at|date:"d/m/Y" }}</td>
                        <td>
                            <a href="{% url 'portfolio_detail' portfolio.pk %}" class="btn btn-sm btn-outline-primary">Dettagli</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="4" class="text-center">Nessun portafoglio trovato.</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}