{% extends "users/base.html" %}
{% block title %}List Default Email{% endblock title %}
{% block content %}

<div class="card card-default">
      <div class="card-header">
        <h2>List Default Email</h2>
		
        

      </div>
    
   <div class="card-body">
    <div class="row">
   <div class="col-xl-6">
   <a class="mb-1 btn btn-pill btn-success" href="{% url 'default_email' %}" role="button" style="text-transform: none;">+ New Default</a>
</div>
<div class="col-xl-6 d-flex justify-content-end">
    <form action="{% url 'default_email' %}" method="post" class="form-inline mb-3">
        <div class="form-group mr-2">
            <input type="text" id="search" name="search" class="form-control" placeholder="Search for domains...">
        </div>
        {% csrf_token %}
        <button type="submit" class="btn btn-danger">Filter</button>
    </form>
	</div>
	</div>
<div class="table-responsive">
    <table class="table table-bordered">
        <thead class="thead-light">
             <tr>
                <th>Email</th>
                <th>destination</th>
               
                <th>Actions</th>
            </tr>
        </thead>
         <tbody id="domainTable">
            {% for email in emails %}
            <tr>
                <td>{{ email.source }}</td>
             <td>
    {% if email.destination == 'pipe@example.com' %}
        {{ email.path }}
    {% else %}
        {{ email.destination }}
    {% endif %}
</td>   
                <td><form action="{% url 'default_email_delete' email.id %}" method="post" style="display:inline;">
                        {% csrf_token %}
                        <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this email ?');">Delete</button>
                    </form>
                    
                    
                </td>
            </tr>
            {% empty %}
            <tr>
                <td colspan="4" class="text-center">No results found.</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
    <!-- No Results Message -->
    <div id="noResults" class="text-center text-danger" style="display:none;">No results found.</div>

</div>
</div>


{% endblock content %}

{% include "users/footer.html" %}