{% extends 'od/base.html' %}
{% load octopusdash_tags %}
{% block content %}


{% for field in form  %}
{% if field.errors %}
    {% for error in field.errors  %}
        {% include 'od/messages/error.html'  with message__title=field.name.title container__id='model_success_message' message__content=error|safe  %}            
    {% endfor %}
{% endif %}
{% endfor %}
    


<form method="post" class="max-w-2xl mx-auto space-y-6">
    {% csrf_token %}
    <div class=" bg-rose-50 dark:bg-rose-900/80 text-rose-600  dark:text-rose-100 p-6 rounded-2xl  ring-1 ring-rose-700/40">
        <div class="flex items-start justify-between mb-4">
            <div>
                <h2 class="text-2xl font-semibold">
                    Delete {{ model_admin.model_name }}: <span class="font-bold">{{ object }}</span>
                </h2>
                <p class="text-sm mt-2 text-rose-700 dark:text-rose-300">
                    Are you sure you want to delete this {{ model_admin.model_name }}?
                    <br>
                    <strong class="text-rose-700 dark:text-rose-300 ">This action cannot be undone.</strong>
                </p>
            </div>
        </div>
        {% if related_objects %}
        <div class="mt-6">
            <ul class="mt-4 pl-6 list-disc space-y-2 text-rose-700 dark:text-rose-200">
                {% for mod, data in related_objects.data.items %}
                    {% for on_delete, related_instances in data.items %}
                        <div>
                            <h3 class="text-lg font-medium my-3 flex items-center gap-2 text-rose-700 dark:text-rose-100">
                                <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-rose-700 dark:text-rose-300" fill="none" viewBox="0 0 24 24"
                                    stroke-width="1.5" stroke="currentColor">
                                    <path stroke-linecap="round" stroke-linejoin="round"
                                        d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
                                </svg>
                                {% if on_delete == 'delete' %}
                                Related objects that will also be <strong> deleted </strong>:
                                {% elif on_delete == 'protcted' %}
                                Related objects that <strong> protected </strong> this instance from deletation 
                                {% elif on_delete == 'do_nothing' %}
                                Related objects that will cause an <strong> integrity </strong> on deletation
                                {% endif %}
                            </h3>
                            {% for instance in related_instances %}
                            <li class="bg-rose-800/50 p-2 rounded-md border border-rose-700">
                                {{ instance }}
                            </li>
                            {% endfor %}
                        </div>
                    {% endfor %}
                {% endfor %}
            </ul>
        </div>
        {% endif %}

        <div class="mt-8 flex items-center justify-between">
            <button type="button" onclick="window.history.back()" class="text-sm text-rose-700 dark:text-rose-300 hover:underline">
                Go back
            </button>
            <button type="submit"
                class="bg-rose-100 hover:bg-rose-200 text-rose-800 font-semibold py-2 px-5 rounded-lg transition duration-150 ease-in-out">
                Yes, Delete
            </button>
        </div>
    </div>
</form>


    
{% endblock %}
