ATS/templates/account/email.html
2026-02-01 19:47:32 +03:00

236 lines
13 KiB
HTML

{% extends "base.html" %}
{% load i18n account %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% get_current_language as LANGUAGE_CODE %}
{% block title %}{% trans "Email Addresses" %} - {{ block.super }}{% endblock %}
{% block content %}
<div class="max-w-4xl mx-auto py-6 px-4">
<!-- Breadcrumb -->
<nav class="mb-6" aria-label="breadcrumb">
<ol class="flex items-center gap-2 text-sm flex-wrap">
<li><a href="{% url 'account_email' %}" class="text-gray-500 hover:underline transition flex items-center gap-1">
<i data-lucide="mail" class="w-4 h-4"></i> {% trans "Account" %}
</a></li>
<li class="text-gray-400">/</li>
<li class="font-semibold" style="color: #9d2235;">{% trans "Email Addresses" %}</li>
</ol>
</nav>
<!-- Header -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6">
<h1 class="text-2xl sm:text-3xl font-bold flex items-center gap-3">
<div class="w-12 h-12 rounded-xl flex items-center justify-center" style="background-color: rgba(157, 34, 53, 0.1);">
<i data-lucide="mail" class="w-6 h-6" style="color: #9d2235;"></i>
</div>
{% trans "Email Addresses" %}
</h1>
</div>
<!-- Info Card -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 mb-6 p-6">
<div class="rounded-lg p-4 border-l-4" style="background-color: #eff6ff; border-color: #9d2235;">
<h6 class="font-bold mb-2 flex items-center gap-2" style="color: #9d2235;">
<i data-lucide="info" class="w-4 h-4"></i>
{% trans "About Email Addresses" %}
</h6>
<p class="text-gray-600 text-sm">
{% trans "These email addresses are linked to your account. You can set primary address, resend verification, or remove an address." %}
</p>
</div>
</div>
<!-- Email Addresses Card -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 mb-6">
<div class="px-6 py-4 border-b border-gray-100" style="background-color: #f8f9fa;">
<h2 class="text-lg font-bold flex items-center gap-2">
<i data-lucide="mail" class="w-5 h-5" style="color: #9d2235;"></i>
{% trans "Linked Email Addresses" %}
</h2>
</div>
<div class="p-6">
<!-- Django Messages -->
{% if messages %}
{% for message in messages %}
<div class="mb-4 p-4 rounded-lg {% if message.tags == 'error' %}bg-red-50 text-red-700{% else %}bg-green-50 text-green-700{% endif %}" role="alert">
<div class="flex items-start gap-3">
<i data-lucide="{% if message.tags == 'error' %}alert-triangle{% else %}check-circle{% endif %}" class="w-5 h-5 flex-shrink-0 mt-0.5"></i>
<span>{{ message }}</span>
</div>
</div>
{% endfor %}
{% endif %}
{% if emailaddresses %}
<div class="space-y-4">
{% for emailaddress in emailaddresses %}
<div class="flex flex-col sm:flex-row sm:items-center justify-between p-4 rounded-lg {% if not forloop.last %}border-b border-gray-200{% endif %} gap-4 bg-white">
<div class="flex-1">
<span class="font-semibold text-gray-900 block">{{ emailaddress.email }}</span>
<!-- Status Badges -->
<div class="flex flex-wrap gap-2 mt-2">
{% if emailaddress.primary %}
<span class="inline-flex items-center gap-1 px-3 py-1 text-xs font-medium bg-blue-100 text-blue-700 rounded-full">
<i data-lucide="star" class="w-3 h-3"></i>
{% trans "Primary" %}
</span>
{% endif %}
{% if emailaddress.verified %}
<span class="inline-flex items-center gap-1 px-3 py-1 text-xs font-medium bg-green-100 text-green-700 rounded-full">
<i data-lucide="check" class="w-3 h-3"></i>
{% trans "Verified" %}
</span>
{% else %}
<span class="inline-flex items-center gap-1 px-3 py-1 text-xs font-medium bg-yellow-100 text-yellow-700 rounded-full">
<i data-lucide="alert-circle" class="w-3 h-3"></i>
{% trans "Unverified" %}
</span>
{% endif %}
</div>
</div>
<div class="flex flex-wrap gap-2">
<!-- Make Primary -->
{% if not emailaddress.primary %}
<form method="post" action="{% url 'account_email' %}" class="inline">
{% csrf_token %}
<input type="hidden" name="email" value="{{ emailaddress.email }}" />
<button type="submit" name="action_primary"
class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white rounded-lg transition-all duration-200"
style="background-color: #9d2235;"
onmouseover="this.style.backgroundColor='#7a1a29'"
onmouseout="this.style.backgroundColor='#9d2235'">
<i data-lucide="star" class="w-4 h-4"></i>
{% trans "Make Primary" %}
</button>
</form>
{% endif %}
<!-- Resend Verification -->
{% if not emailaddress.verified %}
<form method="post" action="{% url 'account_email' %}" class="inline">
{% csrf_token %}
<input type="hidden" name="email" value="{{ emailaddress.email }}" />
<button type="submit" name="action_send"
class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border-2 border-yellow-600 text-yellow-600 rounded-lg hover:bg-yellow-50 transition-all duration-200">
<i data-lucide="send" class="w-4 h-4"></i>
{% trans "Re-send Verification" %}
</button>
</form>
{% endif %}
<!-- Remove -->
{% if not emailaddress.primary %}
<form method="post" action="{% url 'account_email' %}" class="inline">
{% csrf_token %}
<input type="hidden" name="email" value="{{ emailaddress.email }}" />
<button type="submit" name="action_remove"
class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border-2 border-red-600 text-red-600 rounded-lg hover:bg-red-50 transition-all duration-200">
<i data-lucide="trash-2" class="w-4 h-4"></i>
{% trans "Remove" %}
</button>
</form>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% else %}
<p class="p-4 bg-blue-50 text-blue-700 rounded-xl flex items-center gap-3">
<i data-lucide="inbox" class="w-5 h-5"></i>
{% trans "No email addresses found." %}
</p>
{% endif %}
</div>
</div>
<!-- Add Email Card -->
{% if can_add_email %}
<div class="bg-white rounded-xl shadow-sm border border-gray-200">
<div class="px-6 py-4 border-b border-gray-100" style="background-color: #f8f9fa;">
<h2 class="text-lg font-bold flex items-center gap-2">
<i data-lucide="plus-circle" class="w-5 h-5" style="color: #9d2235;"></i>
{% trans "Add Email Address" %}
</h2>
</div>
<div class="p-6">
<form method="post" action="{% url 'account_email' %}" class="space-y-6" id="add-email-form">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="mb-6 p-4 rounded-lg bg-red-50 border border-red-200" role="alert">
<div class="flex items-start gap-3">
<i data-lucide="alert-triangle" class="w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"></i>
<div>
<h5 class="font-semibold text-red-800 mb-1">{% trans "Error" %}</h5>
<p class="text-red-700 mb-0">{{ form.non_field_errors }}</p>
</div>
</div>
</div>
{% endif %}
<div>
<label for="id_email" class="block text-sm font-semibold text-gray-700 mb-2">
{% trans "Email Address" %} <span class="text-red-500">*</span>
</label>
<input type="email"
name="email"
id="id_email"
class="w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition bg-white"
placeholder="{% trans 'Enter your email' %}"
required>
</div>
<button type="submit" name="action_add"
class="w-full inline-flex items-center justify-center gap-2 px-8 py-3 rounded-lg font-medium text-white transition-all duration-200"
style="background-color: #9d2235;"
onmouseover="this.style.backgroundColor='#7a1a29'"
onmouseout="this.style.backgroundColor='#9d2235'">
<i data-lucide="plus" class="w-5 h-5"></i>
{% trans "Add Email" %}
</button>
</form>
</div>
</div>
{% endif %}
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize Lucide icons
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
// Form validation
const form = document.getElementById('add-email-form');
if (form) {
form.addEventListener('submit', function(e) {
const emailInput = document.getElementById('id_email');
const emailValue = emailInput.value.trim();
if (!emailValue) {
e.preventDefault();
alert("{% trans 'Please enter an email address.' %}");
emailInput.focus();
return false;
}
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(emailValue)) {
e.preventDefault();
alert("{% trans 'Please enter a valid email address.' %}");
emailInput.focus();
return false;
}
});
}
});
</script>
{% endblock %}