{% extends 'babybuddy/page.html' %}
{% load i18n imagekit static widget_tweaks %}

{% block title %}{% trans "Children" %}{% endblock %}

{% block breadcrumbs %}
    <li class="breadcrumb-item active" aria-current="page">{% trans "Children" %}</li>
{% endblock %}

{% block content %}
    <h1>
        {% trans "Children" %}
        {% if perms.core.add_child %}
            <a href="{% url 'core:child-add' %}" class="btn btn-sm btn-success">
                <i class="icon-child" aria-hidden="true"></i> {% trans "Add Child" %}
            </a>
        {% endif %}
    </h1>
    {% include 'babybuddy/filter.html' %}
    <div class="table-responsive">
        <table class="table table-borderless table-striped table-hover align-middle">
            <thead>
                <tr>
                    <th><i class="icon-camera" aria-hidden="true"></i></th>
                    <th>{% trans "First Name" %}</th>
                    <th>{% trans "Last Name" %}</th>
                    <th>{% trans "Birth Date" %}</th>
                    <th class="text-center">{% trans "Actions" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for child in object_list %}
                    <tr>
                        <td>
                            {% if child.picture %}
                                {% include "core/child_thumbnail.html" %}
                            {% else %}
                                <img src="{% static 'babybuddy/img/core/child-placeholder.png' %}" width="40" height="40" class="img-fluid rounded-circle" />
                            {% endif %}
                        </td>
                        <th scope="row">
                            <a href="{% url 'core:child' child.slug %}">{{ child.first_name }}</a>
                        </th>
                        <td>{{ child.last_name }}</td>
                        <td>{{ child.birth_datetime }}</td>
                        <td class="text-center">
                            <div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">

                                {% if perms.core.change_child %}
                                    <a href="{% url 'core:child-update' child.slug %}" class="btn btn-warning">
                                        <i class="icon-update" aria-hidden="true"></i>
                                    </a>
                                {% endif %}

                                {% if perms.core.delete_child %}
                                    <a href="{% url 'core:child-delete' child.slug %}" class="btn btn-danger">
                                        <i class="icon-delete" aria-hidden="true"></i>
                                    </a>
                                {% endif %}

                            </div>
                        </td>
                    </tr>
                {% empty %}
                    <tr>
                        <th colspan="5">{% trans "No children found." %}</th>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% include 'babybuddy/paginator.html' %}
{% endblock %}
