{% extends 'base.html' %}

{% block content %}
<div class="tab">
    <button class="tablinks" onclick="openTab(event, 'Songs')">Songs</button>
    <button class="tablinks" onclick="openTab(event, 'Albums')">Albums</button>
</div>

<div id="Songs" class="tabcontent">
    <h2>Song List</h2>
    {% if songs %}
    <table id="songTable" class="display">
        <thead>
            <tr>
                <th>Pista</th>
                <th>Título</th>
                <th>Autor</th>
                <th>Álbum</th>
            </tr>
        </thead>
        <tbody>
            {% for song in songs %}
            <tr>
		<td>{{ song.pista }}</td>
                <td><a href="{{ url_for('paginas.song', song_id=song.id) }}">{{ song.title }}</a></td>
                <td>{{ song.author }}</td>
                <td><a href="{{ url_for('paginas.album', album_id=song.album.id) }}">{{ song.album.name }}</a></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
        <p>No songs found.</p>
    {% endif %}
</div>

<div id="Albums" class="tabcontent">
    <h2>Album List</h2>
    {% if albums %}
        <table id="albumTable" class="display">
            <thead>
                <tr>
                    <th>Nombre</th>
                    <th>Artista</th>
                    <th>Año</th>
                </tr>
            </thead>
            <tbody>
                {% for album in albums %}
                <tr>
                    <td><a href="{{ url_for('paginas.album', album_id=album.id) }}">{{ album.name }}</a></td>
                    <td>{{ album.artist }}</td>
                    <td>{{ album.year }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>No albums found.</p>
    {% endif %}
    <hr>
    <a href="{{ url_for('paginas.add_album') }}" class="button">Añadir nuevo álbum</a>
</div>
<!--
<div id="Albums" class="tabcontent">
    <h2>Albums</h2>
    <ul>
        {% for album in albums %}
        <li>
            <a href="{{ url_for('paginas.album', album_id=album.id) }}">{{ album.name }} by {{ album.artist }} ({{ album.year }})</a>
        </li>
        {% endfor %}
    </ul>
    <hr>
    <a href="{{ url_for('paginas.add_album') }}" class="button">Add New Album</a>
</div>
-->
{% endblock %}
