{% extends "base.html" %}

{% block content %}
<h1 class="mb-4">Category</h1>
<a href="{{ url_for('backoffice.add_category') }}" class="btn btn-primary mb-3">Add New Caregory</a>
<table class="table table-striped">
    <thead>
        <tr>
            <th>Code</th>
            <th>Name</th>
            <th>Image</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        {% for category in all_category %}
        <tr>
            <td>{{ category.code }}</td>
            <td>{{ category.name }}</td>
            <td>
                {% if category.photo_back %}
                <a href="{{ url_for('static', filename=category.photo_url) }}" target="_blanc">
                    <img src="{{ url_for('static', filename=category.photo_back) }}" alt="{{ category.name }}" width="50">
                </a>
                {% else %}
                    No Image
                {% endif %}
            </td>
            <td>
                <a href="{{ url_for('backoffice.edit_category', id=category.id) }}" class="btn btn-sm btn-warning">Edit</a>
                <a href="{{ url_for('backoffice.delete_category', id=category.id) }}" class="btn btn-sm btn-danger">Delete</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}