{% extends 'app/baseAdmin.html' %} {% block content %}


<div class="container">

    {% for message in messages %}
    <div class="alert alert-{{ message.tags }} mb-0 " role="alert">
      <strong>Message: </strong> {{ message }}
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    {% endfor %}


    <div class="row">
 
        <form  method="post" class="col-4 offset-1">
            <h1>Add SubCategory</h1>
            {% csrf_token %}
            <label for="name">Name: </label>
            <input class="form-control" type="slugify" id="name" name="name" value="{{name}}">
            <br>
            <input type="submit" value="Submit">
        </form>

        <div class="col-5">
            <table class="table">

                <tr>
                    <th>Name</th>
                    <th>Update</th>
                    <th>Delete</th>
                </tr>

                {% for category in subCategories reversed %}
                <tr>
                    <td>{{ category }}</td>

                    <td><a class="btn btn-warning" href="{% url 'adminUpdateSubCategory' category.id %}">Update</a></td>

                    <td>
                        <form action="{% url 'adminDeleteSubCategory' category.id %}" method="post">
                            {% csrf_token %}
                            <input class="btn btn-danger" type="submit" value="Delete">
                        </form>
                    </td>
                </tr>
                    
                {% empty %}
                
                <h1>No SubCategory Found</h1>
                
                {% endfor %}

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

{% endblock content%}


