{% extends "admin_base.html" %}
{% block content %}

<div class="container mt-4">
    <h1 class="mb-4">Manage Multi-Day Tours</h1>

    <div class="mb-3">
        <a href="{{ url_for('admin_blueprint.add_tour') }}" class="btn btn-primary">
            <i class="fas fa-plus-circle"></i> Add Multi-Day Tour
        </a>
    </div>

    {% if multi_day_tours %}
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead class="table-dark">
                    <tr>
                        <th>Title</th>
                        <th>Duration</th>
                        <th>Subcategory</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    {% for tour in multi_day_tours %}
                        <tr>
                            <td>{{ tour.title }}</td>
                            <td>{{ tour.duration }}</td>
                            <td>{{ tour.subcategory.name if tour.subcategory else 'N/A' }}</td>
                            <td>
                                <a href="{{ url_for('admin_blueprint.edit_tour', id=tour.id) }}" class="btn btn-sm btn-secondary">
                                    <i class="fas fa-edit"></i> Edit
                                </a>
                                <button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal{{ tour.id }}">
                                    <i class="fas fa-trash-alt"></i> Delete
                                </button>

                                <!-- Delete Confirmation Modal -->
                                <div class="modal fade" id="deleteModal{{ tour.id }}" tabindex="-1" aria-labelledby="deleteModalLabel{{ tour.id }}" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="deleteModalLabel{{ tour.id }}">Confirm Deletion</h5>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                            </div>
                                            <div class="modal-body">
                                                Are you sure you want to delete the tour "{{ tour.title }}"?
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}  <!-- Add this line to close the for loop -->
                </tbody>
            </table>
        </div>
    {% endif %}
</div>

{% endblock %}