ATS/templates/recruitment/applications_list.html
2026-01-29 14:19:03 +03:00

335 lines
22 KiB
HTML

{% extends "base.html" %}
{% load static i18n %}
{% block title %}{% trans "Applications" %} - {{ block.super }}{% endblock %}
{% block content %}
<div class="space-y-6">
<!-- Desktop Header -->
<div class="hidden lg:block">
<!-- Breadcrumb -->
<nav class="mb-6" aria-label="breadcrumb">
<ol class="flex items-center gap-2 text-sm flex-wrap">
<li><a href="{% url 'dashboard' %}" class="text-gray-500 hover:text-temple-red transition flex items-center gap-1">
<i data-lucide="home" class="w-4 h-4"></i> {% trans "Home" %}
</a></li>
<li class="text-gray-400">/</li>
<li class="text-temple-red font-semibold">{% trans "Applications" %}</li>
</ol>
</nav>
<div class="flex justify-between items-start mb-6">
<h1 class="text-3xl font-bold text-gray-900 flex items-center gap-3">
<div class="bg-temple-red/10 p-3 rounded-xl">
<i data-lucide="users" class="w-8 h-8 text-temple-red"></i>
</div>
{% trans "Applications List" %}
</h1>
<a href="{% url 'application_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-6 py-2.5 rounded-xl transition shadow-sm hover:shadow-md">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add New Application" %}
</a>
</div>
<!-- Desktop Filters -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden mb-6">
<div class="bg-gradient-to-br from-temple-red to-[#7a1a29] text-white p-4">
<h5 class="text-lg font-bold flex items-center gap-2">
<i data-lucide="filter" class="w-5 h-5"></i>
{% trans "Filter Applications" %}
</h5>
</div>
<div class="p-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label for="search" class="block text-xs font-semibold text-gray-600 mb-2">{% trans "Search by Name or Email" %}</label>
{% include 'includes/search_form.html' %}
</div>
<div>
<form method="GET" class="flex flex-col sm:flex-row gap-3 items-end">
<div class="flex-1">
<label for="job_filter" class="block text-xs font-medium text-gray-600 mb-2">{% trans "Filter by Job" %}</label>
<select name="job" id="job_filter" class="w-full px-4 py-2 bg-white border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition">
<option value="">{% trans "All Jobs" %}</option>
{% for job in available_jobs %}
<option value="{{ job.slug }}" {% if job_filter == job.slug %}selected{% endif %}>{{ job.title }}</option>
{% endfor %}
</select>
</div>
<div class="flex-1">
<label for="stage_filter" class="block text-xs font-medium text-gray-600 mb-2">{% trans "Filter by Stages" %}</label>
<select name="stage" id="stage_filter" class="w-full px-4 py-2 bg-white border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition">
<option value="">{% trans "All Stages" %}</option>
<option value="Applied" {% if stage_filter == 'Applied' %}selected{% endif %}>{% trans "Applied" %}</option>
<option value="Exam" {% if stage_filter == 'Exam' %}selected{% endif %}>{% trans "Exam" %}</option>
<option value="Interview" {% if stage_filter == 'Interview' %}selected{% endif %}>{% trans "Interview" %}</option>
<option value="Offer" {% if stage_filter == 'Offer' %}selected{% endif %}>{% trans "Offer" %}</option>
</select>
</div>
<div class="flex gap-2">
<button type="submit" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-4 py-2 rounded-lg text-sm transition">
<i data-lucide="filter" class="w-4 h-4"></i> {% trans "Apply Filters" %}
</button>
{% if job_filter or stage_filter or search_query %}
<a href="{% url 'application_list' %}" class="inline-flex items-center gap-2 border border-gray-300 text-gray-600 hover:bg-gray-100 px-4 py-2 rounded-lg text-sm transition">
<i data-lucide="x" class="w-4 h-4"></i> {% trans "Clear" %}
</a>
{% endif %}
</div>
</form>
</div>
</div>
</div>
<!-- Mobile Header -->
<div class="lg:hidden mb-4">
<div class="flex items-center justify-between mb-4">
<h1 class="text-2xl font-bold text-gray-900 flex items-center gap-2">
<div class="bg-temple-red/10 p-2 rounded-lg">
<i data-lucide="users" class="w-6 h-6 text-temple-red"></i>
</div>
{% trans "Applications" %}
</h1>
<a href="{% url 'application_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-4 py-2.5 rounded-xl text-sm transition shadow-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add" %}
</a>
</div>
<!-- Mobile Filters -->
<div class="space-y-3">
<div>
<label for="search" class="block text-xs font-semibold text-gray-600 mb-2">{% trans "Search Applications" %}</label>
{% include 'includes/search_form.html' %}
</div>
</div>
</div>
{% if applications %}
<div id="candidate-list" class="space-y-4">
{# Table View (Default for Desktop) #}
<div class="hidden lg:block bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Name" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Email" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Job" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Major" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Stage" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Hiring Source" %}</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-bold text-gray-700 tracking-wider">{% trans "Created At" %}</th>
<th scope="col" class="px-4 py-3 text-right text-xs font-bold text-gray-700 tracking-wider">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-100">
{% for candidate in applications %}
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-4 py-4 font-medium">
<a href="{% url 'application_detail' candidate.slug %}" class="text-temple-red hover:text-[#7a1a29] transition-colors">{{ candidate.name }}</a>
</td>
<td class="px-4 py-4 text-sm text-gray-700">{{ candidate.email }}</td>
<td class="px-4 py-4">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">
<a href="{% url 'job_detail' candidate.job.slug %}" class="text-white hover:underline">{{ candidate.job.title }}</a>
</span>
</td>
<td class="px-4 py-4">
{% if candidate.is_resume_parsed %}
{% if candidate.professional_category != 'Uncategorized' %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">
{{ candidate.professional_category }}
</span>
{% endif %}
{% else %}
<a href="{% url 'application_list' %}" class="inline-flex items-center gap-2">
<svg class="animate-spin w-6 h-6 text-temple-red" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="5" class="opacity-25"></circle>
<path fill="none" stroke="currentColor" stroke-width="5" d="M25 5a20 20 0 1 1 0 0 40 20 20 0 1 1 0 0-40" class="opacity-75"></path>
</svg>
</a>
{% endif %}
</td>
<td class="px-4 py-4">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">
{{ candidate.stage }}
</span>
</td>
<td class="px-4 py-4">
{% if candidate.hiring_agency and candidate.hiring_source == 'Agency' %}
<a href="{% url 'agency_detail' candidate.hiring_agency.slug %}" class="inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white hover:bg-[#7a1a29] transition-colors">
<i data-lucide="building" class="w-3 h-3"></i> {{ candidate.hiring_agency.name }}
</a>
{% else %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">{{ candidate.hiring_source }}</span>
{% endif %}
</td>
<td class="px-4 py-4 text-sm text-gray-700">{{ candidate.created_at|date:"d-m-Y" }}</td>
<td class="px-4 py-4 text-right">
<div class="inline-flex gap-1">
<a href="{% url 'application_detail' candidate.slug %}" class="inline-flex items-center gap-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 px-3 py-1.5 rounded text-xs transition" title="{% trans 'View' %}">
<i data-lucide="eye" class="w-3.5 h-3.5"></i>
</a>
{% if user.is_staff %}
<a href="{% url 'application_update' candidate.slug %}" class="inline-flex items-center gap-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 px-3 py-1.5 rounded text-xs transition" title="{% trans 'Edit' %}">
<i data-lucide="edit-2" class="w-3.5 h-3.5"></i>
</a>
<button type="button" class="inline-flex items-center gap-1.5 border border-red-300 text-red-600 hover:bg-red-50 px-3 py-1.5 rounded text-xs transition" title="{% trans 'Delete' %}"
onclick="showDeleteModal('{% url 'application_delete' candidate.slug %}', '{{ candidate.name }} ({{ candidate.job.title }})')">
<i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{# Card View (Default for Mobile) #}
<div class="lg:hidden grid grid-cols-1 gap-4">
{% for candidate in applications %}
<div class="bg-white rounded-2xl p-5 shadow-sm border border-gray-100 hover:shadow-md transition-shadow">
<div class="flex flex-col h-full">
<div class="flex justify-between items-start mb-3">
<h5 class="text-lg font-bold text-temple-red mb-0 flex-1">
<a href="{% url 'application_detail' candidate.slug %}" class="hover:text-[#7a1a29] transition-colors">{{ candidate.name }}</a>
</h5>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">{{ candidate.stage }}</span>
</div>
<div class="space-y-2 text-sm text-gray-600 mb-4 flex-1">
<div class="flex items-center gap-2">
<i data-lucide="mail" class="w-4 h-4"></i> {{ candidate.email }}
</div>
<div class="flex items-center gap-2">
<i data-lucide="phone" class="w-4 h-4"></i> {{ candidate.phone|default:"N/A" }}
</div>
<div class="flex items-center gap-2">
<i data-lucide="calendar" class="w-4 h-4"></i> {{ candidate.created_at|date:"d-m-Y" }}
</div>
<div class="flex items-center gap-2">
<i data-lucide="briefcase" class="w-4 h-4"></i>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">
<a href="{% url 'job_detail' candidate.job.slug %}" class="text-white hover:underline">{{ candidate.job.title }}</a>
</span>
</div>
{% if candidate.hiring_agency %}
<div class="flex items-center gap-2">
<i data-lucide="building" class="w-4 h-4"></i>
<a href="{% url 'agency_detail' candidate.hiring_agency.slug %}" class="text-temple-red hover:underline">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-temple-red text-white">{{ candidate.hiring_agency.name }}</span>
</a>
</div>
{% endif %}
</div>
<div class="flex gap-2 pt-3 border-t border-gray-200 mt-auto">
<a href="{% url 'application_detail' candidate.slug %}" class="inline-flex items-center gap-1.5 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-4 py-2 rounded-lg text-sm transition">
<i data-lucide="eye" class="w-3.5 h-3.5"></i> {% trans "View" %}
</a>
{% if user.is_staff %}
<a href="{% url 'application_update' candidate.slug %}" class="inline-flex items-center gap-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 px-3 py-2 rounded-lg text-sm transition">
<i data-lucide="edit-2" class="w-3.5 h-3.5"></i> {% trans "Edit" %}
</a>
<button type="button" class="inline-flex items-center gap-1.5 border border-red-300 text-red-600 hover:bg-red-50 px-3 py-2 rounded-lg text-sm transition" title="{% trans 'Delete' %}"
onclick="showDeleteModal('{% url 'application_delete' candidate.slug %}', '{{ candidate.name }} ({{ candidate.job.title }})')">
<i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
</button>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% include "includes/paginator.html" %}
{% else %}
<div class="bg-white rounded-2xl p-8 shadow-sm border border-gray-100 text-center">
<i data-lucide="users" class="w-16 h-16 text-temple-red mx-auto mb-4"></i>
<h3 class="text-xl font-semibold text-gray-900 mb-2">{% trans "No application found" %}</h3>
<p class="text-gray-500 mb-4">{% trans "Create your first application." %}</p>
{% if user.is_staff %}
<a href="{% url 'application_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-5 py-2.5 rounded-lg transition shadow-md hover:shadow-lg">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Application" %}
</a>
{% endif %}
</div>
{% endif %}
</div>
{# DELETE CONFIRMATION MODAL #}
<div id="deleteModal" class="fixed inset-0 z-50 hidden">
<div class="fixed inset-0 bg-black/50 backdrop-blur-sm"></div>
<div class="flex items-center justify-center min-h-screen p-4">
<div class="bg-white rounded-2xl shadow-xl max-w-md w-full relative">
<div class="flex items-center justify-between p-6 border-b border-gray-200">
<h5 class="text-lg font-bold text-temple-red flex items-center gap-2">
<i data-lucide="alert-triangle" class="w-5 h-5"></i> {% trans "Confirm Deletion" %}
</h5>
<button type="button" onclick="hideDeleteModal()" class="text-gray-400 hover:text-gray-600 transition">
<i data-lucide="x" class="w-5 h-5"></i>
</button>
</div>
<div class="p-6">
<p class="text-gray-700 mb-2">{% trans "Are you sure you want to delete application for" %}:</p>
<p class="text-red-600 text-lg font-bold mb-2" id="modal-item-name"></p>
<p class="text-sm text-gray-500">{% trans "This action is irreversible and application data will be permanently removed." %}</p>
</div>
<div class="flex gap-3 p-6 pt-0">
<button type="button" onclick="hideDeleteModal()" class="flex-1 border border-gray-300 text-gray-700 hover:bg-gray-50 font-medium px-4 py-2.5 rounded-lg transition">
{% trans "Cancel" %}
</button>
<form id="deleteForm" method="post" action="" class="flex-1">
{% csrf_token %}
<button type="submit" class="w-full inline-flex items-center justify-center gap-2 bg-red-600 hover:bg-red-700 text-white font-medium px-4 py-2.5 rounded-lg transition">
<i data-lucide="trash-2" class="w-4 h-4"></i> {% trans "Yes, Delete Permanently" %}
</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block customJS %}
<script>
function showDeleteModal(deleteUrl, itemName) {
const modal = document.getElementById('deleteModal');
const modalItemName = document.getElementById('modal-item-name');
const deleteForm = document.getElementById('deleteForm');
modalItemName.textContent = itemName;
deleteForm.setAttribute('action', deleteUrl);
modal.classList.remove('hidden');
}
function hideDeleteModal() {
const modal = document.getElementById('deleteModal');
modal.classList.add('hidden');
}
// Close modal on backdrop click
document.getElementById('deleteModal').addEventListener('click', function(e) {
if (e.target === this || e.target.classList.contains('backdrop-blur-sm')) {
hideDeleteModal();
}
});
// Close modal on Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
hideDeleteModal();
}
});
lucide.createIcons();
</script>
{% endblock %}